Okay, so I have searched this site and found many tutorials on how to pass variables to another activity with an Intent, but for some reason I still am having trouble getting any thing passed except for a null value. Logcat tells me this:
E/AndroidRuntime( 747): java.lang.RuntimeException: Unable to start activity ComponentInfo{eu.sourceway.tutorials.BetterTabs/eu.sourceway.tutorials.BetterTabs.addonsBrowser}: java.lang.NullPointerException
Here is my starting Activity:
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
String content = links[position];
Intent addonPage = new Intent(ThirdTab.this,addonsBrowser.class);
Bundle b = new Bundle();
b.putString("passed", "http://google.com");
addonPage.putExtras(b);
startActivity(addonPage);
}
});
Here is my Secondary Activity:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
String URL = extras.getString("passed");
browser=new WebView(this);
browser.setWebViewClient(new WebViewClient());
browser.setInitialScale(55);
setContentView(browser);
browser.loadUrl(URL);
}
I set a breakpoint in Eclipse and viewed the passed Bundle variable "extras" in the second Activity, and it show as null, so that and the logcat results are what lead to to conclude that it is not being passed. Also if you look in the first Activity, I actually have the URL being pulled from an ArrayList originally, and then stored in a String variable called content, but that will not pass either. So that is why I subbed the "http://google.com" address. I have tried this with other URLs and still can't pass it. I know the web works, as I have been able o load pages in a webview. The main purpose of this is to have a list that has links from a website, and with the onItemClick, pass the URL to another Activity that has a WebView to load it. The generating of the URLs into the ArraysList works. I have been able to populate the list. The problem is that it force closes as soon as I click on a link because the variable sent is null. Any ideas are much appreciated.