I have an appilcation with an intent filter for main activity
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
because I need an "Open" button in Play Market. But I don't want any shortcuts being created on homescreen or in application list.
How can I prevent creation of shortcuts, saving my "Open" button?
If you have LAUNCHER intent filter you have an Icon, there is no way around this. Keep the icon, no user will ever figure out that he has to navigate to the Playstore and then press open there. You can let the user hide the icon, there's an API for this.
PackageManager p = getPackageManager();
p.setComponentEnabledSetting(getComponentName(),PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
This might require a reboot
Related
I have two android apps
one is for user type 1, it's a launcher app, the user will use this app as a default launcher
The second one is a regular app for user type 2, the user opens the app and uses.
After onwards I have merged two apps into a single app. It's all working fine. But both the users are seeing a screen like this choose which app to be a launcher
Can anyone tell me is it possible to make the app as launcher only for user type 1?
You can declare the launcher component (i.e. the activity receiving the HOME intent) as disabled :
<activity
android:name="my.launcher.Class"
android:enabled="false"
... >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
Then programatically enable it for user 1, using PackageManager.setComponentEnabledSetting :
ComponentName cn = ComponentName.unflattenFromString("my.app.id/my.launcher.Class")
packageManager.setComponentEnabledSetting(cn,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP)
i am use this code for delete icon from homescreen:
PackageManager p = getPackageManager();
p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
But after click button "Delete Icon", app closes, I need to remove the icon and use the application on.
You can't disable the app and still continue using it.
Your code above puts the app into disabled state. The PackageManager will not allow the app to run unless it is re-enabled.
If you want your app to still run, but not have an icon in the all apps drawer of your homescreen, you can by removing the <category android:name="android.intent.category.LAUNCHER" /> from your activity reference in your AndroidMainfest.xml:
<activity android:name=".HiddenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
The app will not appear in the all apps drawer of your home screen, but can be launched from other apps using the following code:
Intent intent = new Intent();
intent.setClassName("app_package_name", "app_package_name.HiddenActivity");
startActivity(intent);
Note: The app with the HiddenActivity must have been started by the user after installing, otherwise the app will be in Stopped state and can't be launched from another application.
I have already finished an Android lock-screen app but my teacher asks me to change it into an app using Windowmanager so that users can not exit the app using HOME button. The idea is that we can make the whole app be a float full-screen window. But I don't know how to change a finished activity into a float window.
You just can't override the HOME button (or "make the HOME button unwork").
There was a time, about in Android 1.6 when you could do that, against Google's wishes. But now you just can't.
Think about it. If you could do that, some app you downloaded from the PlayStore could do that and render your phone unusable.
The closest you can get is adding CATEGORY_HOME as an intent of one of your activities. That way when the user touches the HOME button, he will be presented with the option to choose which activity will open when they touch HOME.
Here you've got an example on how to do it (you don't have to change anything in the Activity classs):
<activity
android:name="com.mpascual.example.HomeActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This line is the relevant one (everything else is just an example):
<category android:name="android.intent.category.HOME"/>
Is there a specifici reason why if I have MainActivity, it has it's own Icon, yet if I create SecondActivity it has a separate icon? If I download an app from the Play store it's all from one icon. Am I just being dumb? Or is there a specific reason why this is. Thanks so much!
Any activity that declares the following intent filter will have an icon in the system's app listing:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
If you only want one icon then only put this intent filter inside your main activity.
Each activity can be launched independently - and thereby can have its own icon - in the Launcher. Also, I think in later APIs, the icon can be displayed inside the Activity itself.
Can any one Help me out "How can we hide or unhide application icon everywhere from phone by any other utility application"
Try this,
PackageManager p = getPackageManager();
p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
This will remove launcher icon from drawer, not applicable for application manager.
No. This is not possible, for security reasons you cannot hide the app from the app listings. The best you can do is to give your app an obscure name or put something like "preferences" behind its title.
remove
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
from the manifest, so your app won't be listed in the launcher anymore ;)
Hiding it completely from the appListing in the deeps of the settings shouldn't be possible afaik.