2011-07-14 134 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」?

相關問題