【问题标题】:No apps can perform this action to open Instagram URL没有应用程序可以执行此操作来打开 Instagram URL
【发布时间】:2020-03-02 05:26:30
【问题描述】:

我尝试为想要关注的用户打开我的 Instagram 页面。我尝试了一些代码来完成这项工作:

private void followInsta() {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("https://www.instagram.com/motivationalquotes.app"));
    try {
        intent.setPackage("com.instagram.android");
        startActivityForResult(Intent.createChooser(intent, mContext.getResources().getString(R.string.app_name)), 1000);
    } catch (Exception e) {
        try {
            Log.e("FollowInsta1>>>", Log.getStackTraceString(e));
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            startActivityForResult(Intent.createChooser(intent, mContext.getResources().getString(R.string.app_name)), 1000);
        } catch (Exception ex) {
            Log.e("FollowInsta2>>>", Log.getStackTraceString(ex));
        }
    }
}

我从 click 事件中调用了它,但它始终打开对话框,并显示一条消息我的应用名称和“没有应用可以执行此操作”

这仅发生在三星 Galaxy J8 设备上。但它通常适用于其他设备。如果有人知道要为这些类型的设备尝试什么,请告诉我。我也试过this 来解决我的问题,但是没有用!

【问题讨论】:

    标签: android


    【解决方案1】:

    试试这个 sn-p:

    Uri uri = Uri.parse("http://instagram.com/_u/motivationalquotes.app");
    Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);
    
    likeIng.setPackage("com.instagram.android");
    
    try {
        startActivity(likeIng);
    } catch (ActivityNotFoundException e) {
        startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://instagram.com/motivationalquotes.app")));
    }
    

    这应该会打开已安装的应用或调用浏览器。

    【讨论】:

    • 它的工作!但是还是不明白为什么有https://不存在?
    猜你喜欢
    • 1970-01-01
    • 2017-05-22
    • 1970-01-01
    • 2014-12-06
    • 1970-01-01
    • 1970-01-01
    • 2013-08-10
    • 1970-01-01
    相关资源
    最近更新 更多