Is There A Way To Monitor Application In Background & Invisible From User
What I want to do is to create an application which can perform it's feature without user interaction. This shouldn't have any appicon at Applications page in Device. After install
Solution 1:
Yes it is possible, and it makes lot of sense. But it takes lot's stuff to do, for example.
1). You need to make your app as boot start-up means whenever user restart mobile or device your app should automatically start's.
<applicationandroid:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme" ><receiverandroid:name=".OnBootReceiver" ><intent-filterandroid:enabled="true"android:exported="false" ><actionandroid:name="android.intent.action.USER_PRESENT" /></intent-filter></receiver><receiverandroid:name=".OnGPSReceiver" ></receiver>
2). Obviously you have to make app with no launcher mode as it's first activity and then call second activity as a service not as an activity.
so basically you have to create something like this.
publicclassAppServiceextendsWakefulIntentService{
// your stuff goes here
}
and while calling service from your mainActivity define it like this.
Intent intent = newIntent(MainActivity.this, AppService.class);
startService(intent);
hideApp(getApplicationContext().getPackageName());
hideApp // use it outside the mainActivity.
privatevoidhideApp(String appPackage) {
ComponentName componentName = newComponentName(appPackage, appPackage
+ ".MainActivity");
getPackageManager().setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
}
3). Then in manifest define this service as like below.
<serviceandroid:name=".AppService" ></service>
Edit
WakefulIntentService
is a new abstract class. Please check below. So create a new java file and paste the beloe code in it.
abstractpublicclassWakefulIntentServiceextendsIntentService {
abstractvoiddoWakefulWork(Intent intent);
publicstaticfinalStringLOCK_NAME_STATIC="test.AppService.Static";
privatestatic PowerManager.WakeLocklockStatic=null;
publicstaticvoidacquireStaticLock(Context context) {
getLock(context).acquire();
}
synchronizedprivatestatic PowerManager.WakeLock getLock(Context context) {
if (lockStatic == null) {
PowerManagermgr= (PowerManager) context
.getSystemService(Context.POWER_SERVICE);
lockStatic = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
LOCK_NAME_STATIC);
lockStatic.setReferenceCounted(true);
}
return (lockStatic);
}
publicWakefulIntentService(String name) {
super(name);
}
@OverridefinalprotectedvoidonHandleIntent(Intent intent) {
doWakefulWork(intent);
//getLock(this).release();
}
}
Post a Comment for "Is There A Way To Monitor Application In Background & Invisible From User"