उपयोग <action android:name="android.intent.action.BOOT_COMPLETED" />
: अपने एप्लिकेशन को आपके प्रकट में अनुमति देने का अनुरोध कर इस सूचना प्राप्त करने के लिए कह सकते हैं।
AndroidManifest.xml
में:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED">
</uses-permission>
में कोड हिस्सा BootBroadcastReceiver
:
public class BootBroadcastReceiver extends BroadcastReceiver {
static final String ACTION = "android.intent.action.BOOT_COMPLETED";
@Override
public void onReceive(Context context, Intent intent) {
// BOOT_COMPLETED” start Service
if (intent.getAction().equals(ACTION)) {
//Service
Intent serviceIntent = new Intent(context, StartOnBootService.class);
context.startService(serviceIntent);
}
}
}
संपादित करें: आप डिवाइस के बारे में बात कर रहे हैं, तो आपके AndroidManifest.xml
के रूप में
<receiver android:name=".BootBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
जोड़ें अनुमति स्क्रीन चालू/बंद होने पर आपको <action android:name="android.intent.action.USER_PRESENT" />
और <action android:name="android.intent.action.SCREEN_ON" />
पंजीकरण करने की आवश्यकता है जब उपयोगकर्ता मौजूद है या स्क्रीन चालू है।
स्रोत
2012-06-23 10:50:40
जब मैं अपना मोबाइल चालू करता हूं तो मुझे एक त्रुटि मिल रही है ... "ऐप को मजबूर होना पड़ा ..."। यह काम नहीं कर रहा है। – Frion3L
आपको कौन सी त्रुटि मिल रही है, क्या आप अपनी पोस्ट को त्रुटि के साथ संपादित कर सकते हैं? –