I wanted to write a small program, deployed on their mobile phone, you can start with their own power, you seek guidance about the great God, because we usually have to manually write, it should be to make a service, but specific to pay attention to what the key is still dazed ah<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Android boot Activity or Service Method
After 4.0 system, you need to have at least one apk activity, after you install the apk up, manually run once. After you can boot up.
Reply:
Landlord, I have studied this problem for a while, and finally found that if the application is not tripartite system privileges, then no solution.
For the following reasons:
Google for security reasons (to avoid malware, viruses, ah do bad things, but also improve efficiency), 4.0 later added a two Flag: FLAG_INCLUDE_STOPPED_PACKAGES and FLAG_EXCLUDE_STOPPED_PACKAGES. Broadcasting System issued with FLAG_EXCLUDE_STOPPED_PACKAGES this flag, in the case did not start the application process can not receive.
Of course, if a user can be defined with FLAG_INCLUDE_STOPPED_PACKAGES broadcast this flag, so you can start even if the application did not receive the broadcast (unfortunately ah! Can be customized tripartite broadcast).
Since the boot time, the process has not yet started, so simply fail to issue broadcasting ACTION_BOOT_COMPLETED systems.
Finally, tell the landlord can only regret, no way!
Reply:
If your phone is already root before, you can apply for root privileges, when first installed, after applying to the root, you can use Linux commands to operate, and this time you can upgrade your application into the system application ... not only the user can not be uninstalled, and then boot you want to do this, then it is service on the line
Reply:
Add
permissions, and then open the boot after receiving the broadcast service
Reply:
In fact, the broadcast can be achieved by creating a start-up classes, inheritance BroadcastReceiver, using INTENT to start. The code
public class StartRecevier extends BroadcastReceiver {
@ Override
public void onReceive (Context context, Intent intent) {
/ / TODO Auto-generated method stub
Intent intent2 = new Intent (context, Main.class);
intent2.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity (intent2);
Log.d ("! Boot_________", "boot from the start");
}
}
No comments:
Post a Comment