2012-08-10 139 views
0

我已經得到強制關閉打開的URL爲此在.jhtml 實例網址: http://www.mtv.com/news/articles/1691428/beck-hansens-song-reader-sheet-music-album.jhtml打開瀏覽器.jhtml強制關閉

的錯誤: 0android.content.ActivityNotFoundException:無活動發現處理意圖{act = android.intent.action.VIEW dat =

我找不出一個體面的解決方法。 有什麼建議嗎?

乾杯, Zed的

CNC中 下面的代碼:

getContext().startActivity(new Intent(Intent.ACTION_VIEW, uri)); 
+0

你給了整個互聯網的權限?並且,發佈您試圖打開瀏覽器的代碼? – Praveenkumar 2012-08-10 05:30:19

+0

發佈您的代碼。 – 2012-08-10 06:01:04

+0

已添加。我用構造函數代替了setData方法 – 2012-08-10 06:03:09

回答

1

致力於通過使用此代碼我的模擬器的罰款。

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    String url = "http://www.mtv.com/news/articles/1691428/beck-hansens-song-reader-sheet-music-album.jhtml"; 
    Intent i = new Intent(Intent.ACTION_VIEW); 
    i.setData(Uri.parse(url)); 
    startActivity(i); 
} 

有一個截圖 -

Screenshot

而且,不要忘記,包括許可

<uses-permission android:name="android.permission.INTERNET"/> 

嘗試上述步驟。

+0

有趣。你認爲這是因爲我使用了構造函數而不是setData方法嗎? – 2012-08-10 06:02:28

+0

也許,你試過我的代碼嗎? – Praveenkumar 2012-08-10 06:06:15

+0

是的。雖然我不能用任何一種方法進行復制。我們用bugsense來捕捉它。 :/ – 2012-08-10 06:07:55

0

試試這個

Uri uri = Uri.parse("http://www.mtv.com/news/articles/1691428/beck-hansens-song-reader-sheet-music-album.jhtml"); 
Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
startActivity(intent); 

希望幫助