Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

url value is not passing to another activity

Options
  • 14-08-2014 12:10am
    #1
    Registered Users Posts: 142 ✭✭


    Hi all. I'm quite new to android development and I am creating an rss feed type app and trying to load the url in a new activity using a WebView. Currently it opens in a browser which works fine but it wont display in the new activity when the link is selected. Any ideas?

    Here is the code from the 1st Activity.

    public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
    Intent i = new Intent(activity, RssSelectionActivity.class);
    i.setData(Uri.parse(listItems.get(pos).getLink()));
    activity.startActivity(i);

    }

    And the code from the 2nd Activity

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rss_selection);


    WebView webView = (WebView)findViewById(R.id.detailsWebView);

    webView.setInitialScale(1);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setScrollbarFadingEnabled(false);


    Thanks in advance


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    It might help if you actually try to reference the url in the second activity.


  • Registered Users Posts: 142 ✭✭nemoisback66


    Thanks for your reply. I did reference the url in the webview like this:

    webview.loadUrl("link of url");

    But this would open the webpage of the actual url specified not the link from the rss feed.

    What way would I pass the link thats clicked to the second activity as there are at least 50+ of these?

    Thanks


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Thanks for your reply. I did reference the url in the webview like this:

    webview.loadUrl("link of url");
    It helps if you include that when you post your code. Off the top of my head, try...

    Sending activity:
    i.putExtra("rssData", listItems.get(pos).getLink());
    

    Second activity:
    if (savedInstanceState != null)
        Uri rssUri = Uri.parse(extras.getString("rssData"));
    


  • Registered Users Posts: 142 ✭✭nemoisback66


    I missed that when I posted up sorry.

    Thanks for your help I'll try that and see how I get on.


Advertisement