Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: I Want Disappear my app icon from launcher

Sanjay:

I want to disappear my App Icon from launcher and app will automatically restart after some time I did code for hiding icon below:


try {
PackageManager p = context.getPackageManager();
ComponentName componentName = new ComponentName("com.package.name", "com.class.name");
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
} catch (Exception e) {
Log.d("[email protected]@", "" + e.toString());
}

this is code for reopening my app after some time


public void initializingTimerTask() {
timerTask = new TimerTask() {
@Override
public void run() {
mHandler.post(new Runnable() {
@Override
public void run() {
if (mIsInForegroundMode == false) {
Intent LaunchIntent=getPackageManager().getLaunchIntentForPackage("com.package.name");
LaunchIntent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(LaunchIntent);
} else {
}
}
});
}
};
}

The error:


11-16 14:10:02.802 18503-18503/com.package.newproject E/AndroidRuntime: FATAL EXCEPTION:
main Process: com.package.newproject, PID: 18503 java.lang.NullPointerException
at com.mspatel.package.newproject.AutoOpenAppService$1$1.run(AutoOpenAppService.java:101)
at android.os.Handler.handleCallback(Handler.java:743)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5212)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)

but when turn to restart application app going to crash please help me.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: I Want Disappear my app icon from launcher

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×