7

For check screenshot and detail, click here

Please give related suggession or code for how to add automatic enable auto start for my app , please check here attached screen shot thanks in advance.

7
  • IF your application had a permission which start your application on start up. Then it automatically come in the list. Becuase the Mi4i security app checks that permission which is mentioned by "mcd" in his answer. Commented Aug 31, 2015 at 14:11
  • 1
    can you please give permission code ? Commented Aug 31, 2015 at 14:20
  • @ChiragKheni I also want to enable autostart for my application. Did you achieved this? Help me out. Commented Nov 27, 2015 at 14:50
  • @Chirag facing same issue, have you got any solution? Commented Feb 22, 2016 at 9:18
  • 1
    Sorry, Not still find any solution for enable auto start option programmatically. we can notify user for this specific device for enable auto start manually. Commented Apr 15, 2016 at 12:59

3 Answers 3

8

Try this...it's working for me. It will open the screen to enable autostart.

String manufacturer = "xiaomi"; if(manufacturer.equalsIgnoreCase(android.os.Build.MANUFACTURER)) { //this will open auto start screen where user can enable permission for your app Intent intent = new Intent(); intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")); startActivity(intent); } 
Sign up to request clarification or add additional context in comments.

4 Comments

How to check if autostart permission already enabled or not. This code always open autostart permission screen . I want to show this screen only when app is not enabled for autostart.
@ved I am also searching for the same... moreover, this code is not able to find the particular activity in some MI phones. I am still searching for the code which will eliminate this issue.
Guys are you find any solution?
How to find in which phone need to do auto-start code? Means I know In MI device it is required for auto-start But don't know about others .
0

Few OEMs including (RedMi) customizes the stack ROM for battery/memory optimization and have blocked the "onDestroy()" and "onTaskRemoved" callbacks. As an user you can prevent the App's service from killing by locking the App. Or, White listing the app by enabling "Autostart" setting for the App. Programmatically you can prompt the user to enable the Autostart for the App Please find details here

Please note: I have tested the Autostart enabling programatically on few devices but found that it does not works always. Please check above link to see the possible options.

Comments

-4

First of all you need a permission at the manifest:

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

Still in manifest you need to add a brodcast receiver within your

<application> 

element:

<receiver android:name="net.example.MyOwnBroadcastReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> 

after that in your Class "MyOwnBroadcastReceiver"

package net.example; public class MyOwnBroadcastreceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent startServiceIntent = new Intent(context, MyService.class); context.startService(startServiceIntent); } } 

You can get more help on the following links:

http://blog.gregfiumara.com/archives/82

http://techblogon.com/android-start-service-on-boot/

1 Comment

I already added above code but not autostart enable by default in Android MI 4i

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.