2013-06-05 62 views
-1
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_browser_detail); 
    Bundle browserDetailBundle = getIntent().getExtras(); 
    if(browserDetailBundle!= null) 
    { 
    detailsToBrowse = browserDetailBundle.getString("EditTextContent"); 
    if (!detailsToBrowse.startsWith("http://") && !detailsToBrowse.startsWith("https://")) 
     detailsToBrowse = "http://" + detailsToBrowse;  
    viewToBrowse = (View)findViewById(R.id.editTextBrowser); 
    } 
    callMe(viewToBrowse); 
} 

public void callMe(View v){ 
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(detailsToBrowse)); 
    startActivity(i); 
} 
+0

你想那裏做什麼? ?試圖在進入此活動後立即加載瀏覽器?或'callMe(View v)'應該是一個按鈕事件? – Rigotti

回答

0

確保,你detailsToBrowse開始 「http://」 或 「https://

if (!detailsToBrowse.startsWith("http://") && !detailsToBrowse.startsWith("https://")) 
    detailsToBrowse = "http://" + detailsToBrowse; 

,改變你的方法

public void callMe(View v){ 
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(detailsToBrowse); 
    startActivity(i); 
} 
+0

仍然問題不固定 – manish

+0

@manisharma你檢查過有關以http://開頭的字符串嗎?據我所知,你發佈的錯誤發生在你錯過的時候... – Rigotti

+0

我做了先生,但問題最終持續了我的意圖決定,而且工作正常:)順便說一句,你關心的問題 – manish

相關問題