调用发送短信界面



/**

* 调用发送短信界面

*/

public void sendSms() {

Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:"));

intent.putExtra("sms_body",

getResources().getString(R.string.smscontent));

startActivity(intent);

}



为程序创建桌面快捷方式

/**

* 为程序创建桌面快捷方式

*/

private void addShortcut() {

Intent shortcut = new Intent(

"com.android.launcher.action.INSTALL_SHORTCUT");



// 快捷方式的名称

shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,

getString(R.string.youbanradio));

shortcut.putExtra("duplicate", false); // 不允许重复创建



// 指定当前的Activity为快捷方式启动的对象: 如com.everest.video.VideoPlayer

// 注意:ComponentName的第二个参数必须加上点号(.),否则快捷方式无法启动相应程序

ComponentName comp = new ComponentName(this.getPackageName(), "."

+ this.getLocalClassName());

shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(

Intent.ACTION_MAIN).setComponent(comp));



// 快捷方式的图标

ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(

this, R.drawable.icon);

shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);



sendBroadcast(shortcut);

}

在Mainfest中加入权限

<!-- 创建桌面快捷方式权限 -->

<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>



返回首页

/**

* 返回首页

*/

public void goBackMainPage() {

Intent homeIntent = new Intent(Intent.ACTION_MAIN);

homeIntent.addCategory(Intent.CATEGORY_HOME);

startActivity(homeIntent);

setNotiType(R.drawable.icon_small,

getResources().getString(R.string.youbanradio));

}



安装apk

// 安装apk

public void installApk(String name) {

if (name == null || name.length() <= 0 || name.lastIndexOf(".apk") <= 0) {

return;

}

String fileName = Environment.getExternalStorageDirectory()

+ FileUtil.APK_PATH + name;

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setDataAndType(Uri.fromFile(new File(fileName)),

"application/vnd.android.package-archive");

startActivity(intent);

downloadApkName = name;

exit();

}


TelephonyManager tm =(TelephonyManager) getSystemService(Service.TELEPHONY_SERVICE);

tm.listen(newTeleStateListener(), PhoneStateListener.LISTEN_CALL_STATE);



class TeleStateListener extends PhoneStateListener {



@Override

public void onCallStateChanged(int state, String incomingNumber) {

// TODO Auto-generatedmethod stub

super.onCallStateChanged(state, incomingNumber);



AudioPlayer mPlayer = AppConst.getInstance()

.getAudioPlayerController().getAudioPlayer();



switch (state) {

case TelephonyManager.CALL_STATE_OFFHOOK:

break;

case TelephonyManager.CALL_STATE_IDLE:

if (mPlayer.getStartPlayState()) {

if (!mPlayer.getPlayer().isPlaying() &&!mPlayer.isPause()) {

mPlayer.getPlayer().start();

}

}

break;

case TelephonyManager.CALL_STATE_RINGING:

if (mPlayer.getStartPlayState()) {

if (mPlayer.getPlayer().isPlaying()) {

mPlayer.getPlayer().pause();

}

}

break;

}

}



}

更多相关文章

  1. android 模拟器常用命令
  2. Android实现启动页停留几秒然后自动跳转到App首页的方法
  3. Android(安卓)6.0 Launcher3隐藏小部件与APP icon
  4. Android中通过Intent调用其他应用的方法
  5. 【NFC】Android(安卓)NFC API Reference中英文
  6. android应用程序跳转到系统的各个设置页面和通过Intent action
  7. android设置背景
  8. Android系统Home应用程序(Launcher)的启动过程源代码分析
  9. 使用intent调用Android系统自带应用

随机推荐

  1. [置顶] android adb adbd analyse
  2. android studio 接入androidannotations
  3. [Android GMS 认证] CTS 问题列表之 CtsS
  4. Android通知栏图标显示网络图片
  5. android camera根据屏幕图像大小设置显示
  6. Android BaseAdapter基本使用及数据刷新
  7. Android 数字格式化
  8. android自定义dialog样式
  9. android 获取音乐文件的内置专辑图片
  10. android 10 system app 读取sysfs_leds a