2
当系统没有启动完成时,我需要将数据写入文件。 我使用广播接收器“android.intent.action.REBOOT”下面是我的代码和清单文件重新启动广播接收机?
public class broadcastreceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Log.i("LOG_TAG","rebooted");
}
清单文件:
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".broadcast"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.example.broadcastreceiver.broadcastreceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.REBOOT">
<intent-filter>
<action android:name="android.intent.action.REBOOT" />
</intent-filter>
</receiver>
</application>
,但我不能写,甚至一个日志时重新启动。 注:我想DONOT在广播接收器使用Bootcompleted行动
我需要维护接收器一个用于重新启动,一个用于bootcompleted .i通过android.developers.com广播recivers提示可能使用重新启动操作。 – RanjitRock
+1为答案。你应该使用BootCompleted,如果你想赶上日志输出 – androidnoob
,因为“android.intent.action.REBOOT”被系统使用,它只能在side用户应用程序中使用。我们需要用平台key.i来签署apk使用boot_completed ..感谢每一个 – RanjitRock