Android:Calling startActivity() from outside of an Activity context错误

 
 


出现提示:

Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?


可能在一个Service中启动一个Acitivity:加上 FLAG_ACTIVITY_NEW_TASK

String fileName = task.getFullFileName();
				Intent intent = new Intent(Intent.ACTION_VIEW);
				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
				this.getApplicationContext().startActivity(intent);
	            



你可能感兴趣的:(android,service,File)