找到你要的答案

Q:Running code including context in another class

Q:在另一个类中包含上下文的运行代码

I want to run below code in my DownloadService class when the download finishes:

Intent localIntent = new Intent("android.intent.action.ATTACH_DATA");
localIntent.setDataAndType(Uri.fromFile(new File(imagePath)), "image/jpg");
localIntent.putExtra("mimeType", "image/jpg");      
localIntent.addCategory(Intent.CATEGORY_DEFAULT);
FullImage.this.startActivityForResult(Intent.createChooser(localIntent, "set as"), 200);

What do you offer me to solve my issue??

我想运行下面代码在我上课的时候下载完成的下载服务:

Intent localIntent = new Intent("android.intent.action.ATTACH_DATA");
localIntent.setDataAndType(Uri.fromFile(new File(imagePath)), "image/jpg");
localIntent.putExtra("mimeType", "image/jpg");      
localIntent.addCategory(Intent.CATEGORY_DEFAULT);
FullImage.this.startActivityForResult(Intent.createChooser(localIntent, "set as"), 200);

你给我什么来解决我的问题??

answer1: 回答1:

Use AsyncTask and run above code in onPostExecute(Result)

在onpostexecute使用AsyncTask并运行上面的代码(结果)

android  android-context