0

I have a listview with some items and each item points to a webpage. When I click items webpage opens in default browser without any problem. But when I'm done with webpage and press on device's back button, it quits the browser and goes straight into home screen. I want it to go back into application (listview) instead. How can I do it?

I tried different devices and the result is still the same. I even tried with my Samsung Note 10.1 tablet. This tablet has a widget called "Active applications" that shows all running applications in a window. Now, when I run my application and click on device's home button it goes on home screen and I see my application in "active applications" window. But when I click an Item on my listview I see home screen for a split of a second and then it opens default browser but if I click on home button while browser is open, I only see that browser in "active applications" window. My application is destroyed before it opens the browser.

My onItemClickListener method looks like this:

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        String[] urls  = getResources().getStringArray(R.array.ticket_sale_url);
        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urls[position]));
        startActivity(browserIntent);
    }
});
oxyt
  • 1,816
  • 3
  • 23
  • 33
  • http://stackoverflow.com/questions/4038479/android-go-back-to-previous-activity – ChristofferPass May 06 '15 at 12:18
  • 2
    I think your problem is device specific because Android's default behavior is what you want. – Muzaffer May 06 '15 at 12:21
  • @wisemann My application has only 1 activity with multiple fragments. Cloud this be the problem? – oxyt May 06 '15 at 12:32
  • No. You don't finish your activity when clicked an item. Your activity still lives and Android has to return it. – Muzaffer May 06 '15 at 12:44
  • @wisemann I tried with a different brand and the result is still same. I realize that when I click on an item in the listview it shows home screen for a split of a second and then open the browser. I think activity destroys before open the browser. Or I am completely wrong :) – oxyt May 06 '15 at 13:54
  • 1
    Can you post manifest(just activity)? and check developer options, there is an option "Don't keep activities". If it is enabled, disable it and try again. – Muzaffer May 06 '15 at 14:08
  • @wisemann you are the man :) I found this line in manifest/activity `android:noHistory="true"`. – oxyt May 06 '15 at 14:13

0 Answers0