Android App get crashed when webview open -


i trying transfer variable (url_1) value main activity webview. when click button app crashed. use putextra doesn't work. please have on below code.

public class customadapter extends baseadapter{     string [] result;     context context;     int [] imageid;     private static layoutinflater inflater=null;     public customadapter(mainactivity mainactivity, string[] prgmnamelist, int[] prgmimages) {         // todo auto-generated constructor stub         result=prgmnamelist;         context=mainactivity;         imageid=prgmimages;         inflater = ( layoutinflater )context.                 getsystemservice(context.layout_inflater_service);     }     @override     public int getcount() {         // todo auto-generated method stub         return result.length;     }      @override     public object getitem(int position) {         // todo auto-generated method stub         return position;     }      @override     public long getitemid(int position) {         // todo auto-generated method stub         return position;     }      public class holder     {         textview tv;         imageview img;     }     @override     public view getview(final int position, view convertview, viewgroup parent) {         // todo auto-generated method stub         holder holder=new holder();         view rowview;         rowview = inflater.inflate(r.layout.new_custom_list, null);         holder.tv=(textview) rowview.findviewbyid(r.id.textview1);         holder.img=(imageview) rowview.findviewbyid(r.id.imageview1);         holder.tv.settext(result[position]);         holder.img.setimageresource(imageid[position]);         rowview.setonclicklistener(new onclicklistener() {             @override             public void onclick(view v) {                 // todo auto-generated method stub                 intent myintent = null;                 if (position == 0) {                     customadapter.this.context.startactivity(new intent(customadapter.this.context, balanceactivity.class));                 }                 if (position == 1) {                     string url_1 = "http://www.facebook.com";                     myintent.putextra("url", url_1);                     customadapter.this.context.startactivity(new intent(customadapter.this.context, webshow1.class));                  }             }         });         return rowview;     } } 

your myintent null. creating with:

intent myintent = null; 

and without initializing want put data inside:

myintent.putextra("url", url_1); 

i don´t know want myintentbut must initialized, in activity example

myintent = getintent(); 

in adapter, can reference context like:

intent myintent = ((activity) context).getintent(); 

and sure intent not null before doing it:

if(myintent!=null){ //do stuff } 

or, if example want start new activity (in case):

 intent myintent = null;                 if (position == 0) {                     myintent = new intent(customadapter.this.context, balanceactivity.class);                     customadapter.this.context.startactivity(myintent);                 }                 if (position == 1) {                      myintent = new intent(customadapter.this.context, webshow1.class);                     string url_1 = "http://www.facebook.com";                     myintent.putextra("url", url_1);                     customadapter.this.context.startactivity(myintent);                  } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -