2011-07-14 37 views
0

我试图从应用程序的对话框中打开Android中的默认浏览器与特定的网址。我用个人的对话框类,与公共方法插入clickeable文本:从应用程序启动网络浏览器

public class PictureInfoView extends Dialog { 
private Context mContext; 

public PictureInfoView(Context context) { 
    super(context); 
    mContext = context; 
    .... 
} 
public void addSource(final String newSource) { 
    TextView t = new TextView(mContext); 
    t.setClickable(true); 
    t.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View arg0) { 
      dismiss(); 
      try{ 
      Intent viewIntent = new Intent("Intent.ACTION_VIEW", 
        Uri.parse("http://www.google.com")); 
      mContext.startActivity(viewIntent); 
      }catch(Exception e){ 
       Log.e("CC", "PictureInfoView: " + e.getMessage()); 
      } 
     } 
    }); 
    v.addView(t, 0); 
} 
... 
} 

但是当单击文本时,一个异常被gerenerated此消息:

"No activity found to handle Intent { act=Intent.ACTION_VIEW dat=http://www.google.com }" 

问题出在哪里?

谢谢大家! =)

回答

2

Intent viewIntent = new Intent("Intent.ACTION_VIEW", 
       Uri.parse("http://www.google.com")); 

应该像

Intent viewIntent = new Intent(Intent.ACTION_VIEW, 
       Uri.parse("http://www.google.com")); 

;或用 “android.intent.action.VIEW”(那从Intent.ACTION_VIEW字符串,see here

+0

感谢alextsc。 ..这是问题...一个noob失败=) –

0

偶然的,你有没有在清单中包含使用权限android:name =“android.permission.INTERNET”?

相关问题