我想知道为什么我的应用程序在android真正的手机上启动后没有立即运行?我的应用程序在启动几秒钟后就开始运行了。
我的代码是
public class AutoStart extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
Intent i = new Intent(context, MyActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}我的活动正在运行,但在启动几秒钟后就完成了。有没有可能缩短这几秒钟?
我想立即运行我的应用程序。我不想允许用户访问电话。
发布于 2013-06-05 14:25:07
这可以增加你的优先级,但仍然会有一些延迟。因为android首先加载它的操作系统,然后所有其他的活动就开始了。
<receiver
android:name=".AutoStart"
android:enabled="true"
android:exported="true"
<intent-filter android:priority="1000">
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>https://stackoverflow.com/questions/16932701
复制相似问题