I have a view with few buttons, each buttons suppose to open a different url in firefox, but instead after one of the buttons clicked and the url opens in firefox, all the other buttons just opens firefox but not navigating to their url.
this is the code I am using for the intent:
Intent i = new Intent("android.intent.action.MAIN");
i.setComponent(new ComponentName("org.mozilla.firefox", "org.mozilla.firefox.App"));
Bundle b = new Bundle();
b.putBoolean("new_window", true); //suppose to set the new window
i.putExtras(b);
i.addCategory("android.intent.category.LAUNCHER");
i.setData(Uri.parse(url));
startActivity(i);
How should I code it to open each button click on new tab.
Use the Intent.ACTION_VIEW :
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// ...
openpage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("your url")));
}
});
Should work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.