我有一些文件要通过Bluetooth
. 这是我的代码
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayList<Uri> uris = new ArrayList<Uri>();
String multifile[] = {"/sdcard/file1.txt", "/sdcard/file2.txt", "/sdcard/file3.txt"};
int len = multifile.length;
Intent Int = new Intent();
Int.setAction(android.content.Intent.ACTION_SEND_MULTIPLE);
Int.setType("*/*");
String packageName = null;
String className = null;
boolean found = false;
PackageManager pm = getPackageManager();
List appsList = pm.queryIntentActivities( Int, 0);
ArrayList<ResolveInfo> list = (ArrayList<ResolveInfo>) pm.queryIntentActivities(Int, PackageManager.PERMISSION_GRANTED);
for(ResolveInfo info: list) {
packageName = info.activityInfo.packageName;
if( packageName.equals("com.android.bluetooth")) {
className = info.activityInfo.name;
found = true;
break;// found
}
}
if (!found) {
Toast.makeText(MainActivity.this, "not foud bluetooth",
Toast.LENGTH_SHORT).show();
// exit
}
Int.setClassName(packageName, className);
for(int i=0;i<len;i++) {
File file=new File(multifile[i]);
uris.add(Uri.fromFile(file));
}
Int.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivity(Int);
onStop(); //stop here till all file have been sent
//delete all files which is to be send
}
}
所有三个文件都已发送,但问题是在完成Mainactivity
之前执行 continue,Intent Int
因为在发送文件之前所有文件都已删除 请帮助如何停止执行,Mainactivity
直到 Int 发送所有文件