相关疑难解决方法(0)

如何检测可以处理请求的Intent操作的Android应用程序?

我想通过twitter,facebook或设备上提供的其他方式分享短信.我写了下一个代码:

    Intent share = new Intent(Intent.ACTION_SEND);
    share.putExtra(Intent.EXTRA_TEXT, "Here's some text for Twitter.");
    startActivity(Intent.createChooser(share, "Share this via"));       
Run Code Online (Sandbox Code Playgroud)

但是,如果没有可以执行此操作的应用程序,屏幕上会显示"无此类应用程序"对话框.如果找不到处理程序,我想检测这些应用程序并禁用此功能.我怎么能这样做?

android android-intent

6
推荐指数
1
解决办法
2688
查看次数

点击url链接时,android禁用onclick事件

我有textview包含urlswww.google.com.为此,textview还创建了一个onclicklistener.

我的问题是,当用户点击www.google.com时,链接由a使用activity,但之后activity onclick也会创建该事件.但我不想onclick在用户点击网址时创建活动.

onclick当用户点击http : //www.google.com,market:// android等网址时,texview是否可以禁用事件.

编辑1:我在下面添加了详细信息.

            TextView entry = (TextView) v
                    .findViewById(R.id.textViewEntryText);
            entry.setText(Html.fromHtml(String.format("%s",
                    (CharSequence) displayText)));
            entry.setMovementMethod(LinkMovementMethod.getInstance());
Run Code Online (Sandbox Code Playgroud)

在使用链接创建textview之后,再将其他事件放在其他文本上.

            entry.setOnClickListener((new View.OnClickListener() {

                // TODO Auto-generated method stub

                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    }
                }
            }));
Run Code Online (Sandbox Code Playgroud)

现在,当用户点击url链接时,我不希望其他onclick事件适用于链接.

events android textview

5
推荐指数
1
解决办法
2565
查看次数

android.content.ActivityNotFoundException当链接不包含http时

我的应用程序允许用户在使用有限的HTML时键入消息给其他用户.我允许的一件事是使用超链接.

例:

<a href="www.google.com">Google</a>

我正在TextView通过以下方法填充:

txtview.setMovementMethod(LinkMovementMethod.getInstance());
txtview.setText(Html.fromHtml(items.get(position).getBody()));
Run Code Online (Sandbox Code Playgroud)

如果用户创建的超链接没有前缀http到url,则应用程序崩溃并出现以下异常:

FATAL EXCEPTION: main
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=www.google.com (has extras) }
    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
Run Code Online (Sandbox Code Playgroud)

如果网址带有前缀http,一切正常.

例:

<a href="http://www.google.com">Google</a>

我怎样才能防止这种情况发生?

android textview

4
推荐指数
1
解决办法
1445
查看次数

标签 统计

android ×3

textview ×2

android-intent ×1

events ×1