添加快捷方式和删除快捷方式:

private void addShortcut() {
Intent shortcut = new Intent(
"com.android.launcher.action.INSTALL_SHORTCUT"); // 快捷方式的名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
getString(R.string.app_name));
shortcut.putExtra("duplicate", false); // 不同意反复创建 // 指定当前的Activity为快捷方式启动的对象
ComponentName comp = new ComponentName(this.getPackageName(),
getClass().getName());
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);
} /**
* 删除程序的快捷方式。 */
private void deleteShortcuts() {
Intent shortcut = new Intent(
"com.android.launcher.action.UNINSTALL_SHORTCUT"); // 快捷方式的名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
getString(R.string.app_name)); // 指定当前的Activity为快捷方式启动的对象
ComponentName comp = new ComponentName(this.getPackageName(),
getClass().getName());
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(
Intent.ACTION_MAIN).setComponent(comp)); sendBroadcast(shortcut);
}

发邮件:

	public boolean sendEmail(String to[], String subject, String body,
String attachementFilePath) {
final Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, to);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
if (attachementFilePath != null) {
Uri attachmentUri = null;
try {
File file = new File(attachementFilePath);
if (file == null) {
Log.d("[RC] Mail", "File error: " + attachementFilePath);
} else if (!file.exists()) {
Log.d("[RC] Mail", "File does not exist: "
+ attachementFilePath);
} else if (!file.canRead()) {
Log.d("[RC] Mail", "File can't be read: "
+ attachementFilePath);
} else if (!file.isFile()) {
Log.d("[RC] Mail", "Invalid file: " + attachementFilePath);
} else {
attachmentUri = Uri.fromFile(file);
Log.d("[RC] Mail", "Attachement path[size=" + file.length()
+ "]: " + attachementFilePath);
Log.d("[RC] Mail",
"Attachement URI: " + attachmentUri.toString());
}
} catch (java.lang.Throwable ex) {
Log.e("[RC] Mail", "Error: " + ex.toString());
} if (attachmentUri != null) {
emailIntent.putExtra(Intent.EXTRA_STREAM, attachmentUri);
}
}
emailIntent.setType(PLAIN_TEXT);
List<ResolveInfo> availableSoft = (List<ResolveInfo>) mContext
.getPackageManager().queryIntentActivities(emailIntent,
PackageManager.MATCH_DEFAULT_ONLY);
if (availableSoft.size() <= 0) {
return false;
}
mContext.startActivity(Intent.createChooser(emailIntent, mContext
.getResources().getString(R.string.menu_sendEmail))); return true;
}

默认使用Google chrome打开WebView:

//new Intent(Intent.ACTION_VIEW, uri)
public void startActiviyByChromeIfExists(Context context,
Intent intent) { try {
Log.d("startActiviyByChromeIfExists",
"Intent Scheme: " + intent.getScheme());
} catch (Exception e) {
} if (context != null && intent != null) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
List<ResolveInfo> availableSoft = (List<ResolveInfo>) context
.getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo info : availableSoft) {
if ("com.android.chrome".equals(info.activityInfo.packageName)) {
intent.setComponent(new ComponentName(
info.activityInfo.packageName,
info.activityInfo.name));
context.startActivity(intent);
return;
}
}
if (availableSoft.size() == 0) {
try {
Toast.makeText(mContext, R.string.setting_no_browser_installed, Toast.LENGTH_LONG).show();
} catch (Exception e) {
Log.e("startActiviyByChromeIfExists", e.getMessage());
} } else {
context.startActivity(intent);
}
}
}

声明权限:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

关机广播:

<receiver android:name=".ShutdownReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN"/>
</intent-filter>
</receiver>

接受开机广播:

  <receiver android:name="BootBroadcast" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>

android一些系统相关的东西的更多相关文章

  1. input系统——android input系统

    AndroidInput系统--JNI NativeInputManager InputManger InputReader AndroidInput系统--InputReader AndroidIn ...

  2. 图解Android - Android GUI 系统 (2) - 窗口管理 (View, Canvas, Window Manager)

    Android 的窗口管理系统 (View, Canvas, WindowManager) 在图解Android - Zygote 和 System Server 启动分析一 文里,我们已经知道And ...

  3. Android动画学习(一)——Android动画系统框架简介

    2015-11-09补充:Drawable Animation极有可能是Frame Animation 这几天在找工作,面试的时候被问到了Android动画,之前完全没接触过这部分,直接给懵了,当然其 ...

  4. 使用kvm虚拟出Centos6.5系统相关步骤

    使用kvm虚拟出Centos6.5系统相关步骤 kvm是啥东西,亲们自行百度哇,一两句话也说不清楚,直接进主题使用宿主机虚拟出一台centos6.5的系统,当然其他系统也可以的,考虑到企业常用服务器系 ...

  5. 图解Android - Android GUI 系统 (1) - 概论

    Android的GUI系统是Android最重要也最复杂的系统之一.它包括以下部分: 窗口和图形系统 - Window and View Manager System. 显示合成系统 - Surfac ...

  6. 图解Android - Android GUI 系统 (5) - Android的Event Input System

    Android的用户输入处理 Android的用户输入系统获取用户按键(或模拟按键)输入,分发给特定的模块(Framework或应用程序)进行处理,它涉及到以下一些模块: Input Reader: ...

  7. android 修改系统的dialog样式

    android 修改系统的dialog样式 一.觉得自定义配置文件麻烦?那就来修改系统自定义XML文件来实现修改系统dialog的样式吧. 如果是在XML中样式:首先来说下样式.  在 Style.x ...

  8. Android核心分析之十五Android输入系统之输入路径详解

       Android用户事件输入路径 1 输入路径的一般原理 按键,鼠标消息从收集到最终将发送到焦点窗口,要经历怎样的路径,是Android GWES设计方案中需要详细考虑的问题.按键,鼠标等用户消息 ...

  9. [Android] 输入系统(一)

    Android输入系统是人与机器交互最主要的手段.我们通过按键或者触碰屏幕,会先经由linux产生中断,进行统一的处理过后,转换成Android能识别的事件信息,然后Android的输入系统去获取事件 ...

随机推荐

  1. Weblogic修改后台日志输出级别

  2. webstorm启动bug

    场景描述: win10系统下,webstorm(32位)经常遇到无法启动的情况. 解决方案: 重启电脑. 1.win10系统需要更新时,webstorm无法启动,此为win10 bug,重启时,系统自 ...

  3. import Tkinter的时候报错

    在看到图形界面编程的时候,需要导入Tkinter模块,从而在解释器中进行import Tkinter,然后...报错如下: >>> from tkinter import * Tra ...

  4. ansible服务模块和组模块使用

    本篇文章主要是介绍ansible服务模块和组模块的使用. 主要模块为ansible service module和ansible group moudle,下面的内容均是通过实践得到,可以直接运行相关 ...

  5. 【LeetCode】118 & 119 - Pascal's Triangle & Pascal's Triangle II

    118 - Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, ...

  6. Spark connect to Database

    Cannect to Cassandra: 用spark-cassandra-connector, 注意spark,cassandra和connector的版本要配套,Cassandra至少要版本2以 ...

  7. 关于Windows API、CRT和STL二三事

    1.本文编写目的    本文是为了帮助一些人弄清一些关于Windows API, C运行时程序库(CRT), 和标准C++库(STL)的基本概念.有很多人甚至是有经验的程序员在这些概念上是含糊不清的甚 ...

  8. Java正则表达式获取网页所有网址和链接文字

    ;         pos1= urlContent.indexOf(strAreaBegin)+strAreaBegin.length();         pos2=urlContent.inde ...

  9. SQL SERVER 2008 R2 SP3 发布

    今晚上刚发现,微软很低调啊 下载地址:http://www.microsoft.com/zh-cn/download/details.aspx?id=44271 整合SP3的Express系列版本还没 ...

  10. STL源码剖析读书笔记--第四章--序列式容器

    1.什么是序列式容器?什么是关联式容器? 书上给出的解释是,序列式容器中的元素是可序的(可理解为可以按序索引,不管这个索引是像数组一样的随机索引,还是像链表一样的顺序索引),但是元素值在索引顺序的方向 ...