xml - About android.intent.action.BOOT_COMPLETED -


i write sample learn broadcastreceiver..but when reboot phone,the app broke down.don't know why.here sourse code , manifest.xml:

 public class mainactivity extends activity {      @override     protected void oncreate(bundle savedinstancestate) {        super.oncreate(savedinstancestate);        setcontentview(r.layout.activity_main);     }      public class bootcompletereceiver extends broadcastreceiver     {        @override       public void onreceive(context context, intent intent) {           toast.maketext(context,"boot complete",toast.length_long).show();        }     }   } 

 <?xml version="1.0" encoding="utf-8"?>  <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.boot"     android:versioncode="1"     android:versionname="1.0" >    <uses-sdk       android:minsdkversion="14"       android:targetsdkversion="17" />   <uses-permission android:name="android.permission.access_network_state"/>    <uses-permission android:name="android.permission.receive_boot_completed" />   <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=".bootcompletereceiver" >           <intent-filter>               <action android:name="android.intent.action.boot_completed" />            </intent-filter>                  </receiver>   </application> 

``

so,here code above.i should add more details..but have said all..

you not have class named com.example.boot.bootcompletereceiver, @ least based on code have shown in answer.

while have class named bootcompletereceiver:

  • it inner class of mainactivity, , bootcompletereceiver not named com.example.boot.bootcompletereceiver

  • it regular inner class of mainactivity (no static keyword), , android not create instance of anyway, if had right name in manifest

either move bootcompletereceiver regular standalone java class in own .java file, or make public static class inside mainactivity. in latter case, fully-qualified class name manifest entry com.example.boot.mainactivity$bootcompletereceiver.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -