android - Launch app in background, start it to run over Cellular and collect data -
I'm new to Android and I'm trying to launch an app in the background (such as SpeedTest) and click it Ask them to start it and move on to the background and return data results as output. I hope all this to be in the background. I have written that the code launches the app in the foreground
private static final string TAG = "MyService"; @Ivarried Public Eye on On Bind (intro ARG0) {return tap; } @ Override Public Wide On Creativity (Toast) Make Text (this, "Congratulations! My service is made", Toast. LNNHHLOG). Show (); Log D. (Tag, "On Crate"); Intent = getPackageManager (). GetLaunchIntentForPackage ("org.zwanoo.android.speedtest"); If (intent! = Zero) {/ * We have found that activity starts activity now / intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); StartActivity; } And {/ *] bring the user to the market or let them choose the app? * / Intent = new intent (Intent.ACTION_VIEW); Intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); Intent.setData (Uri.parse ("Market: // details? Id =?" + "Org.zwanoo.android.speedtest")); StartActivity; }} @ Override Public Wide Onstage (Intent Intent, Intestate Eyed) {Toast. Maketext (this, "My Service Start", Toast. LNNHT_LOG). Show (); Log D. (Tag, "ontart"); } @ Override Public Empty OnDestoy () {Toast. Make Text (this, "MySwive Stop", Toast. LNNHHLoad) Show (); Log D. (Tag, "ontoroy"); } }
Comments
Post a Comment