Advertisement
Combreal

android-paste-template.java

Aug 6th, 2022 (edited)
1,299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.20 KB | None | 0 0
  1. -----------------------------activity_main.xml
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9. -----------------------------AndroidManifest.xml
  10.  
  11.  
  12.  
  13.     <uses-permission android:name="android.permission.CAMERA"/>
  14.     <uses-permission android:name="android.permission.RECORD_AUDIO"/>
  15.     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  16.     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  17.     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  18.     <uses-permission android:name="android.permission.INTERNET"/>
  19.  
  20.  
  21.  
  22. -----------------------------build.gradle
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. -----------------------------MainActivity.java
  31.  
  32.  
  33.  
  34.     private Button bCapture;
  35.  
  36.     @Override
  37.     protected void onCreate(Bundle savedInstanceState) {
  38.         super.onCreate(savedInstanceState);
  39.         setContentView(R.layout.activity_main);
  40.  
  41.         if (checkSelfPermission(Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_DENIED ||
  42.                 checkSelfPermission(Manifest.permission.ACCESS_NETWORK_STATE) == PackageManager.PERMISSION_DENIED ||
  43.                 checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED ||
  44.                 checkSelfPermission(Manifest.permission.INTERNET) == PackageManager.PERMISSION_DENIED ||
  45.                 checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_DENIED ||
  46.                 checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
  47.             //permission not enabled, request it
  48.             String[] permission = {Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO, Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.INTERNET, Manifest.permission.WRITE_EXTERNAL_STORAGE};
  49.             requestPermissions(permission, 1000);
  50.         }
  51.  
  52.         bCapture.setOnClickListener(new View.OnClickListener() {
  53.             @Override
  54.             public void onClick(View v) {
  55.                 Toast.makeText(this, "Clicked Capture!", Toast.LENGTH_SHORT).show();
  56.             }
  57.         });
  58.     }
  59.  
  60.  
  61.  
  62. -----------------------------myclass.java
  63.  
  64.  
  65.  
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement