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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

url value is not passing to another activity

  • 13-08-2014 11:10pm
    #1
    Registered Users, Registered Users 2 Posts: 138 ✭✭


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


    I missed that when I posted up sorry.

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


Advertisement