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
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.

url value is not passing to another activity

  • 14-08-2014 12:10AM
    #1
    Registered Users, Registered Users 2 Posts: 137
    ✭✭


    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


Welcome!

It looks like you're new here. Sign in or register to get started.

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, Registered Users 2 Posts: 137 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, Registered Users 2 Posts: 137 nemoisback66
    ✭✭


    I missed that when I posted up sorry.

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


Welcome!

It looks like you're new here. Sign in or register to get started.
Advertisement