Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. AssetManager assetManager = getAssets();
  2.  
  3. InputStream in = null;
  4. OutputStream out = null;
  5.  
  6. try {
  7. in = assetManager.open("PreloaderAIR-captive-runtime.apk");
  8.  
  9. FileOutputStream outputStream = openFileOutput("PreloaderAIR-captive-runtime.apk", Context.MODE_PRIVATE);
  10.  
  11. byte[] buffer = new byte[1024];
  12.  
  13. int read;
  14.  
  15. while((read = in.read(buffer)) != -1) {
  16. outputStream.write(buffer, 0, read);
  17. }
  18.  
  19. in.close();
  20. in = null;
  21.  
  22. outputStream.close();
  23. outputStream = null;
  24.  
  25. Intent intent = new Intent(Intent.ACTION_VIEW);
  26.  
  27. File a = new File(getApplicationContext().getFilesDir(),"PreloaderAIR-captive-runtime.apk");
  28. if (a.exists())
  29. {
  30. Uri b = Uri.fromFile(a);
  31. intent.setDataAndType(b,"application/vnd.android.package-archive");
  32. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  33. startActivity(intent);
  34. }
  35.  
  36. } catch(Exception e) {
  37. System.out.println(e.getMessage());
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement