自启动apk,不是开机自启动apk 在A.apk中通过代码安装B.apk,我想实现:在B.apk安装完成后,自动启动B.apk,如何实现???开机自动运行apk,倒是监听下启动完成的消息就行了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有难度有一个思路是监听PACKAGE_ADDED,但经测试,此action在xml中静态注册无效,同求解... 没试过,但应该是监听Intent。 监听这个apk安装完毕的消息不行吗 只要在A.apk进程没被关闭的情况下,A.apk中监听PACKAGE的广播,从A.apk中去启动B.apk还是可以的。 楼上兄弟,PACKAGE的广播,具体是啥值? android.intent.action.PACKAGE_ADDED接收这个广播if(Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())){ Toast.makeText(context, "有应用被添加", Toast.LENGTH_LONG).show(); }然后接收到之后去启动 我想我这话说得不好,自己总结如下:1.在正规渠道下安装B.apk,对package的监听如果写在xml里,B.apk是监听不到自己安装成功时系统发出的package_added的action。但如果写在A.apk的xml里,A.apk是可以监听到B.apk的安装情况的。2.在真机调试下,写在xml里同样可以监听到B.apk的安装消息。(现在我也很感到奇怪...)1.建个BroadcastReceiver类package lab.sodino.appadded;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.widget.Toast;public class ApkReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { Toast toast = Toast.makeText(context, intent.getAction(),Toast.LENGTH_LONG); toast.show(); }}2.在代码中注册或在XML里注册监听器,这儿写出xml的情况: <receiver android:name="ApkReceiver"> <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED"></action> <action android:name="android.intent.action.PACKAGE_CHANGED"></action> <action android:name="android.intent.action.PACKAGE_DATA_CLEARED"></action> <action android:name="android.intent.action.PACKAGE_INSTALL"></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> <data android:scheme="package"></data> </intent-filter> </receiver> 我觉得 你可以去看看 pacakage的 一个service, 然后在里面添加 包广播 可能是可以实现的 监听PACKAGE_ADDED 我试过 也监听不到 OpenGL如何播放yuv视频 android模拟器联网 求教:在自己定义的VIEW里面,二次调用含有editView的对话框会出错 android2.3 USB网卡,USB以太网 Android 能否用纯C/C++ 开发? camera系统代码中的CE是什么意思? Android中调用JNI,报无法找到包的原因。 如何把 v2.1的ExpandeView对应的dialog宽度变长? android中不能引用java.awt.Color,那这个怎么解决? 自定义Adapter的getView方法不执行 像素问题 请问哪里有开放的流媒体播放的api,最好是rtsp协议的,其他的也可以
if(Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())){
Toast.makeText(context, "有应用被添加", Toast.LENGTH_LONG).show();
}然后接收到之后去启动
1.在正规渠道下安装B.apk,对package的监听如果写在xml里,B.apk是监听不到自己安装成功时系统发出的package_added的action。但如果写在A.apk的xml里,A.apk是可以监听到B.apk的安装情况的。
2.在真机调试下,写在xml里同样可以监听到B.apk的安装消息。(现在我也很感到奇怪...)1.建个BroadcastReceiver类package lab.sodino.appadded;import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;public class ApkReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) {
Toast toast = Toast.makeText(context, intent.getAction(),Toast.LENGTH_LONG);
toast.show();
}
}
2.在代码中注册或在XML里注册监听器,这儿写出xml的情况:
<receiver android:name="ApkReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"></action>
<action android:name="android.intent.action.PACKAGE_CHANGED"></action>
<action android:name="android.intent.action.PACKAGE_DATA_CLEARED"></action>
<action android:name="android.intent.action.PACKAGE_INSTALL"></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>
<data android:scheme="package"></data>
</intent-filter>
</receiver>