Android Development Settings Start automatically

Source: Internet
Author: User

Original: http://blog.csdn.net/kevinmeng_ini58/article/details/7700786

Fragment One:

[HTML]View Plaincopy
  1. <!--boot-up
  2. <receiver android:name=". Autostartreceiver ">
  3. <intent-filter>
  4. <action android:name="Android.intent.action.BOOT_COMPLETED"/>
  5. <category android:name="Android.intent.category.HOME"/>
  6. </intent-filter>
  7. </receiver>

Android:name= ". Autostartreceiver "Autostartreceiver.java to handle the operation after boot start

Fragment two: in 4. X version on the test must be added to the sentence, test equipment, the original road N90 8G

[HTML]View Plaincopy
    1. <!--boot-up
    2. <uses-permission android:name="Android.permission.RECEIVE_BOOT_COMPLETED" />



Fragment Three: Autostartreceiver.java

[Java]View Plaincopy
    1. Import Android.content.BroadcastReceiver;
    2. Import Android.content.Context;
    3. Import android.content.Intent;
    4. /**
    5. * Enable Boot
    6. * @author Owner
    7. */
    8. Public class Autostartreceiver extends Broadcastreceiver {
    9. @Override
    10. public void OnReceive (context context, Intent Intent) {
    11. Intent i = new Intent (context, mainactivity.   Class);
    12. I.setflags (Intent.flag_activity_new_task);
    13. Context.startactivity (i);
    14. }
    15. }

Android Development Settings Start automatically

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.