Android 常用代码集合.docxVIP

  • 4
  • 0
  • 约6.34千字
  • 约 11页
  • 2017-07-09 发布于河南
  • 举报
Android 常用代码集合

Android 常用代码集合分类:Android2010-07-20 10:001270人阅读评论(8)收藏举报view plaincopy to clipboardprint?span style=font-family: Arial, Verdana, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); 这篇文章主要记录一些我常用的一些代码段,方便以后查阅,不断更新中/span 1 调用浏览器载入某网址view plaincopy to clipboardprint?Uri uri = Uri.parse(); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); 2 Broadcast接收系统广播的intent 监控应用程序包的安装删除view plaincopy to clipboardprint?publicclass getBroadcast extends BroadcastReceiver { @Overridepublicvoid onReceive(Context context, Intent intent) { if(Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())){ Toast.makeText(context, 有应用被添加, Toast.LENGTH_LONG).show(); } elseif(Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())){ Toast.makeText(context, 有应用被删除, Toast.LENGTH_LONG).show(); } elseif(Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction())){ Toast.makeText(context, 有应用被替换, Toast.LENGTH_LONG).show(); } elseif(Intent.ACTION_CAMERA_BUTTON.equals(intent.getAction())){ Toast.makeText(context, 按键, Toast.LENGTH_LONG).show(); } } } 需要声明的权限如下AndroidManifest.xmlview plaincopy to clipboardprint??xml version=1.0 encoding=utf-8? manifest xmlns:android=/apk/res/androidpackage=zy.Broadcastandroid:versionCode=1android:versionName=1.0 application android:icon=@drawable/icon android:label=@string/app_name activity android:name=.Broadcastandroid:label=@string/app_name intent-filter action android:name=ent.action.MAIN / category android:name=ent.category.LAUNCHER / /intent-filter /activity receiver android:name=getBroadcast android:enabled=true intent-filter action android:name=ent.action.PACKAGE_ADDED/action !-- action android:name=ent.action.PACKAGE_CHANGED/action-- action android:name=ent.action.PACKAGE_REMOVED/action action android:name=ent.action.PACKAGE_REPLACED/action !-- action android:name=ent.action.PACKAGE_RESTARTED/action-- !-- action android:name=ent.action.PACKAGE_INSTALL/action-- action android:name=ent.action.CAMERA_BUTTON/action data android:sche

文档评论(0)

1亿VIP精品文档

相关文档