java - Android widget listview items onclick startActivity 调用外部应用
问题描述
我必须确保通过单击小部件列表中的项目,对外部应用程序产生了意图。
意图:
Intent appIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://instagram.com/_u/"+str));
appIntent.setPackage("com.instagram.android");
Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/"+str));
try {
startActivity(appIntent);
} catch (ActivityNotFoundException ex) {
startActivity(webIntent);
}
我试图把它放在 getViewAt 中,但它不起作用。
Intent intent;
try {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://status?status_id=" + listItem.id));
intent.setPackage("com.twitter.android");
} catch (ActivityNotFoundException ex) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/" + listItem.username + "/status/" + listItem.id));
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
remoteView.setOnClickFillInIntent(R.id.widgetItemContainer, intent);
解决方案
推荐阅读
- sparql - 我如何计数和过滤?(维基数据查询)
- android - 如何测试 SingleLiveEvent
多变的? - angular - 迁移到 Angular 7 后缓冲区未定义错误
- reactjs - 用户向下滚动时获取更多内容
- grails - Grails:从数据库加载 gsps
- vba - Coreldraw VBA 在颜色分配中添加字符串
- python - 错误“找不到满足烧瓶要求的版本(来自版本:)找不到烧瓶的匹配分布”
- docker - Docker设计:容器之间交换数据还是将多个进程放在一个容器中?
- python - 如何使用三引号?
- java - JnrpeClient:java.net.SocketException:软件导致连接中止:recv 失败