通过意向检查是否用户有一定的消息应用程序安装的Android [英] Checking through intent if user has certain messaging app installed android
问题描述
我这个code工作而拉古斯瓦米纳坦帮助我与我的发现在原来的职位:<一href=\"http://stackoverflow.com/questions/34990682/how-to-show-both-texting-and-dialer-apps-with-a-single-intent-on-android/34995375?noredirect=1#comment57725010_34995375\">How同时显示短信和拨号器的应用程序在Android上使用?一个意图。
I am working with this code which Ragu Swaminathan helped me with on my original post found at: How to show both texting and dialer apps with a single Intent on Android?.
final List<Intent> finalIntents = new ArrayList<Intent>();
final Intent textIntent = new Intent(Intent.ACTION_VIEW);
textIntent.setType("text/plain");
textIntent.setData(Uri.parse("sms:"));
final PackageManager packageManager = getActivity().getPackageManager();
final List<ResolveInfo> listCam = packageManager.queryIntentActivities(textIntent, 0);
for (ResolveInfo res : listCam) {
final String packageName = res.activityInfo.packageName;
final Intent intent = new Intent(textIntent);
intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
intent.setPackage(packageName);
finalIntents.add(intent);
}
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:121"));
Intent chooserIntent = Intent.createChooser(
callIntent, "Select app to share");
chooserIntent.putExtra(
Intent.EXTRA_INITIAL_INTENTS, finalIntents.toArray(new Parcelable[]{}));
startActivity(chooserIntent);
我有这样的code,它snackup分离安装在用户手机短信和拨号应用程序将弹出,并允许他们选择一个要么发送消息/叫人。
I have this code that brings up snackup separating sms and dialer apps installed on users phone and allows them to pick one to either send a message / call a person.
我想知道的是,它是possbile再添一节这个小吃店,如果用户已经安装的WhatsApp或安装的另一个specfic应用程序,检查。
What I want to know is, is it possbile to add another section on this snackbar that checks if the user has whatsapp installed or another specfic app installed.
此外,作为新到Android,我试图玩弄了code,但最终搞乱它。我想这样做的另一件事就是创建一个类似论文的部分;
Also, being new to android, I have tried playing around with the code but ended up messing it up. another thing that I would like to do is create sections like theses;
短信应用:
......
......
......
拨号应用程序:
......
......
......
WhatsApp的:
Whatsapp:
......
任何帮助是值得欢迎的,请让我知道如果我的问题不明确。
Any help is welcomed, please let me know if my question is not clear.
编辑;
推荐答案
您可以使用 getPackageInfo
法
PackageManager pm = getPackageManager();
PackageInfo pi = pm.getPackageInfo(certainAppPackageName, 0);
if (pi != null) {
//app is installed, do smth
}
谷歌播放链接存在包名。
例如:
Google play links exist package names. For example:
https://play.google.com/store/apps/details?id=org.telegram.messenger
其中, org.telegram.messenger
是包名
这篇关于通过意向检查是否用户有一定的消息应用程序安装的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!