i am trying to make launcher in android.i want admin to hide few apps from user.
i have done for admin-user log in. now i want admin to select some apps which should not be seen by user.
so that,when user log in he/she should see only those apps which are allowed by admin.
List<ResolveInfo> availableActivities = manager.queryIntentActivities(i, 0);
for(ResolveInfo ri:availableActivities){
AppDetail app = new AppDetail();
app.label = ri.loadLabel(manager);
app.name = ri.activityInfo.packageName;
app.icon = ri.activityInfo.loadIcon(manager);
apps.add(app);
}
i have got the list of apps..
kindly help.
Use PackageManager to get all the installed apps and then write the following code:
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, package_name); //package_name is the name of the application's package you want to hide
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
That should do it.
You can maintain application information i.e name,package name and icon in SQLite databse.
On the basis of selection , you can show applications to user.
Related
I have the following code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, urlToShare);
// determine fb app
List<ResolveInfo> matches = context.getPackageManager().queryIntentActivities(intent, 0);
for (ResolveInfo info : matches) {
String pkg = info.activityInfo.packageName.toLowerCase();
if (pkg.startsWith("com.facebook.katana") || pkg.startsWith("com.facebook.lite")) {
intent.setPackage(info.activityInfo.packageName);
}
}
context.startActivity(intent);
About 100-200 users press the share button of which more than 70% have an app installed. That would mean 70-150 shares per day. However I get maybe one share per day! I think that most of the time the FB app ignores the link, it only opens the share dialog but WITHOUT THE LINK. On my mobile device it works ok (the link is part of the share) but for others it is not.
Am I doing something wrong? Or Facebook doesn't allow to share links like this?
I am trying to get the package name of the default android clock (stock clock).
This is the intent I use to open the stock clock.
Intent i = new Intent(AlarmClock.ACTION_SHOW_ALARMS);
I have tried
i.getPackage();
But this returns null. Is there a way to get the package name of the default clock in android, in any phone?
But this returns null
That is because you have not set the package name in the Intent.
Is there a way to get the package name of the default clock in android, in any phone?
Not really, as there is no concept of a "default clock" in Android.
However, you can use PackageManager and queryIntentActivities() to see what activities will respond to the Intent that you have constructed.
Hope this will help you:
final PackageManager packageManager = this.getPackageManager();
Intent intent = new Intent(AlarmClock.ACTION_SHOW_ALARMS);
List<ResolveInfo> packages = packageManager.queryIntentActivities(intent,0);
for(ResolveInfo res : packages){
String package_name = res.activityInfo.packageName;
Log.w("Package Name: ",package_name);
}
I have a couple of app stores installed on my Android device, like Play Store(default), Amazon App Store, Aptoide, etc. Can someone tell me the intent that is needed to display the list of all those app stores?
When the user clicks on a link I want him to give the option to select the app store through which the app is to be downloaded. I am unable to find the intent action that would help me do this.
I finally found the answer to my own question. I used the following piece of code to display the app stores installed on the device.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?"));
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(intent, 0);
if (!resInfo.isEmpty()){
ArrayList<String> storePacakgeNames = new ArrayList<String>();
for (ResolveInfo resolveInfo : resInfo) {
storePacakgeNames.add(resolveInfo.activityInfo.packageName);
}
}
In my widget, when the widget is opened, I want it to open up a new page that shows links to the users already installed applications. The users must be able to add and delete the links as needed and the links would be updated if that application was deleted from the users device. I have already created the ability in my widget to open a new class but I don't know on how to go about linking to user applications. How can I do this?
You have to get the Activity of the app and link it with URI.
For example:
Uri.parse("market://details?id=" + facebookpackagename);
will load the Facebook app from within your app.
Try this code:
PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for(ApplicationInfo packageInfo:packages){
if( pm.getLaunchIntentForPackage(packageInfo.packageName) != null ){
String currAppName = pm.getApplicationLabel(packageInfo).toString();
//This app is a non-system app
}
else{
//System App
}
}
In Samsung devices com.sec.android.email is the default In-Built Mail client, but in HTC it is com.htc.android.mail.. My question is is there any way to get the default mail client package name in android device irrespective of the different company builds..
This isn't a complete answer, but here is how to get a list of Activities that can send message/rfc822:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
PackageManager pkgManager = context.getPackageManager();
List<ResolveInfo> activities = pkgManager.queryIntentActivities(intent, 0);
You can iterate over the list. See ResolveInfo documentation for fields of interest.