Android - Java - Have app run when device boots up -


i having bit of issue here, code seems right, not doing expecting too.

i have app , run when device boots up. when device boots up, application not run, expecting.

first in manifest, added uses-permission receive_boot_completed:

<uses-permission android:name="android.permission.receive_boot_completed" /> 

then in manifest added receiver , activity inside application:

<application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >         <activity             android:name=".mainactivity"             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=".bootreceiver"             android:enabled="true"             android:permission="android.permission.receive_boot_completed" >             <intent-filter>                 <action android:name="android.intent.action.boot_completed" />                  <category android:name="android.intent.category.default" />             </intent-filter>         </receiver>          <activity             android:name=".bootreceiver"             android:label="@string/title_activity_boot_receiver" >         </activity>     </application> 

and created bootreceiver activity looks this:

import android.content.broadcastreceiver; import android.content.context; import android.content.intent;  public class bootreceiver extends broadcastreceiver{      @override     public void onreceive(context context, intent intent) {         intent = new intent(context, mainactivity.class);           i.addflags(intent.flag_activity_new_task);         context.startactivity(i);       } } 

when install app, boot device, app not run right when device boots up.

i not understand doing wrong here. code wrong? got ideas?

bootreceiver not activity class extends broadcast receiver.

update manifest, enough

     <application     android:allowbackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >   <uses-permission android:name="android.permission.receive_boot_completed" />     <activity         android:name=".mainactivity"         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=".bootreceiver"         android:enabled="true"         >         <intent-filter>             <action android:name="android.intent.action.boot_completed" />          />         </intent-filter>     </receiver>   </application> 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -