当前位置: 代码迷 >> Android >> android应用程序剔除,添加处理
  详细解决方案

android应用程序剔除,添加处理

热度:68   发布时间:2016-05-01 18:51:03.0
android应用程序删除,添加处理

?可以在广播里处理相应的action

?

先在AndroidManifest.xml添加

?? ??? ??? <intent-filter>
?????????? ??? ??? <action android:name="android.intent.action.PACKAGE_ADDED" />
???????????? ??? <action android:name="android.intent.action.PACKAGE_CHANGED"></action>
???????????? ??? <action android:name="android.intent.action.PACKAGE_REMOVED"></action>??
???????????? ??? <action android:name="android.intent.action.PACKAGE_REPLACED"></action>??
???????????? ??? <action android:name="android.intent.action.PACKAGE_RESTARTED"></action>
???????????? ??? <action android:name="android.intent.action.PACKAGE_INSTALL"></action>??
?????????????? <data android:scheme="package"></data>
??? ??? ??? </intent-filter>

?

然后在广播里处理
??? ??? if(Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction()))
??? ??? {??
??? ??? ??? _Debug.println("ACTION_PACKAGE_ADDED" + callerlocUtil + intent.getDataString());
??????????? Toast.makeText(context, "有应用被添加", Toast.LENGTH_LONG).show();??
??? ??? }??
??????? else if(Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction()))
??????? {
??????? ??? _Debug.println("ACTION_PACKAGE_REMOVED" + callerlocUtil + intent.getDataString());
??????????? Toast.makeText(context, "有应用被删除", Toast.LENGTH_LONG).show();??
??????? }??
??????? else if(Intent.ACTION_PACKAGE_CHANGED.equals(intent.getAction()))
??????? {?
??????? ??? _Debug.println("ACTION_PACKAGE_CHANGED" + callerlocUtil + intent.getDataString());
??????????? Toast.makeText(context, "有应用被改变", Toast.LENGTH_LONG).show();?
??????? }??
??????? else if(Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction()))
??????? {
??????? ??? _Debug.println("ACTION_PACKAGE_REPLACED" + callerlocUtil + intent.getDataString());
??????????? Toast.makeText(context, "有应用被替换", Toast.LENGTH_LONG).show();
??????? }
??????? else if(Intent.ACTION_PACKAGE_RESTARTED.equals(intent.getAction()))
??????? {?
??????? ??? _Debug.println("ACTION_PACKAGE_RESTARTED" + callerlocUtil + intent.getDataString());
??????????? Toast.makeText(context, "有应用被重启", Toast.LENGTH_LONG).show();?
??????? }??
??????? else if(Intent.ACTION_PACKAGE_INSTALL.equals(intent.getAction()))
??????? {?
??????? ??? _Debug.println("ACTION_PACKAGE_INSTALL" + callerlocUtil + intent.getDataString());
??????????? Toast.makeText(context, "有应用被安装", Toast.LENGTH_LONG).show();?
??????? }

?

?

?

?

?

  相关解决方案