Ticket #1078 (closed enhancement: fixed)

Opened 7 years ago

Last modified 6 years ago

Android version 4 auto startup changes

Reported by: albert Owned by: gpress
Priority: minor Milestone:
Component: - Version: 0.1t
Severity: Medium Keywords:
Cc: jcappos, akos, mkaplan Blocking:
Blocked By:

Description

Anthony Prieur (see  here for a project of his) kindly points out that

A change was need to get the AutoStart working on Android 4.x. Android 4.x needs the app to start ASAP so if any delay (like postDelayed with 30s) the app is not lauched/killed. To fix you need an async task starting as quick as possible (in less than 5sec)

Thanks a lot! We'll want to make our autostarter work cross-version.

Anthony also shares this piece of code with us that does the trick for him:

	@Override
	public void onReceive(final Context context, Intent intent) {
		new AsyncStart(context).execute();
	}
	
	public class AsyncStart extends AsyncTask<Void, Integer, String> {
		
	    private Context context;
		
	    public AsyncStart(Context context) {
	        super();
	        this.context = context;
	    }
	
	    @Override
	    protected String doInBackground(Void... params) {
	    	while (true) {		
				boolean mounted = installConfig.isInstallPathMounted();
				if(mounted) {
			    	  Intent serviceIntent = new Intent();
			    	  serviceIntent.setAction("com.seattleonandroid.ScriptService");
			    	  context.startService(serviceIntent);
			    	  break;
				}
				else {
					try {
						Thread.sleep(2000);
					} catch (InterruptedException e) {}
				}	
	    		
			}
	    	
	        return null;
	    }
	}

Change History

Changed 7 years ago by justinc

  • cc mkaplan added

Changed 6 years ago by justinc

  • owner changed from albert to gpress
  • status changed from new to assigned

Changed 6 years ago by gpress

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in r6267, big thank you to Anthony Prieur for his help.

Note: See TracTickets for help on using tickets.