android - How to open browser as a foreground activity like some custom dialog? -
i using below code onclick of listview opens link in browser. there way open same browser in catchy small foreground activity custom dialog or popup ? has tried ?
public void onitemclick(adapterview<?> parent, view view, int pos, long id) { intent = new intent(intent.action_view); i.setdata(uri.parse(listitems.get(pos).getlink())); activity.startactivity(i); }
thanks, advance
editing code per tarun suggestion :
public class listlistener extends activity implements onitemclicklistener { // list item's reference list<rssitem> listitems; // calling activity reference activity activity; public listlistener(list<rssitem> alistitems, activity anactivity) { listitems = alistitems; activity = anactivity; } /** * start browser url rss item. */ public void onitemclick(adapterview<?> parent, view view, int pos, long id) { /*intent = new intent(intent.action_view); i.setdata(uri.parse(listitems.get(pos).getlink())); activity.startactivity(i);*/ alertdialog.builder alert = new alertdialog.builder(listlistener.this); alert.settitle("title here"); webview wv = new webview(this); wv.loadurl(listitems.get(pos).getlink()); wv.setwebviewclient(new webviewclient() { @override public boolean shouldoverrideurlloading(webview view, string url) { view.loadurl(url); return true; } }); alert.setview(wv); alert.setnegativebutton("close", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int id) { } }); alert.show(); }
}
error :
07-22 13:18:43.465: e/androidruntime(22759): fatal exception: main 07-22 13:18:43.465: e/androidruntime(22759): java.lang.nullpointerexception 07-22 13:18:43.465: e/androidruntime(22759): @ android.content.contextwrapper.getapplicationinfo(contextwrapper.java:139) 07-22 13:18:43.465: e/androidruntime(22759): @ android.view.contextthemewrapper.gettheme(contextthemewrapper.java:65) 07-22 13:18:43.465: e/androidruntime(22759): @ android.app.alertdialog.resolvedialogtheme(alertdialog.java:142) 07-22 13:18:43.465: e/androidruntime(22759): @ android.app.alertdialog$builder.(alertdialog.java:359) 07-22 13:18:43.465: e/androidruntime(22759): @ com.itcuties.multicategoryrssreader.listeners.listlistener.onitemclick(listlistener.java:43) 07-22 13:18:43.465: e/androidruntime(22759): @ android.widget.adapterview.performitemclick(adapterview.java:298) 07-22 13:18:43.465: e/androidruntime(22759): @ android.widget.abslistview.performitemclick(abslistview.java:1283) 07-22 13:18:43.465: e/androidruntime(22759): @ android.widget.abslistview$performclick.run(abslistview.java:3074) 07-22 13:18:43.465: e/androidruntime(22759): @ android.widget.abslistview$1.run(abslistview.java:4147) 07-22 13:18:43.465: e/androidruntime(22759): @ android.os.handler.handlecallback(handler.java:615) 07-22 13:18:43.465: e/androidruntime(22759): @ android.os.handler.dispatchmessage(handler.java:92) 07-22 13:18:43.465: e/androidruntime(22759): @ android.os.looper.loop(looper.java:137) 07-22 13:18:43.465: e/androidruntime(22759): @ android.app.activitythread.main(activitythread.java:4898) 07-22 13:18:43.465: e/androidruntime(22759): @ java.lang.reflect.method.invokenative(native method) 07-22 13:18:43.465: e/androidruntime(22759): @ java.lang.reflect.method.invoke(method.java:511) 07-22 13:18:43.465: e/androidruntime(22759): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1008) 07-22 13:18:43.465: e/androidruntime(22759): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:775) 07-22 13:18:43.465: e/androidruntime(22759): @ dalvik.system.nativestart.main(native method)
alertdialog.builder alert = new alertdialog.builder(this); alert.settitle("title here"); webview wv = new webview(this); wv.loadurl("http:\\www.google.com"); wv.setwebviewclient(new webviewclient() { @override public boolean shouldoverrideurlloading(webview view, string url) { view.loadurl(url); return true; } }); alert.setview(wv); alert.setnegativebutton("close", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int id) { } }); alert.show();
Comments
Post a Comment