Androidruntimeexception “calling startactivity() from outside the activity context requires flag_activity_new_task flag”
•
Android
I created multiple layouts in listview, but when I click I to get an androidruntimeexception, "calling startactivity() from the activity context requires the flag_activity_new_task flag. Is this really what you want?"
I added
My intention, but I received the same message= (
@Override
public View getView(int position, View convertView, ViewGroup parent) {
retval=LayoutInflater.from(getApplicationContext()).inflate(R.layout.layout_anuncio, null);
ImageView image=(ImageView) retval.findViewById(R.id.imageAD);
LoadAds loadAds= new CargaAnuncios();
clickUrl = LoadAds.cargaImagenAnuncio(image, mContext, GlobalInfo.ANUNCIO_CARRIL_PORTADA);
image.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view) {
Bundle bundle=new Bundle();
bundle.putString("url", clickUrl);
Intent intent =new Intent(mContext,CustomWebView.class);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
}
});
return retval;
}
resolvent:
Replace getapplicationcontext () with this. Most likely, you should use getapplicationcontext () anywhere in your code - only getapplicationcontext () when you especially need an application object
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码