mirror of
				https://github.com/SimpleMobileTools/Simple-Camera.git
				synced 2025-06-27 09:02:59 +02:00 
			
		
		
		
	launch the app on Hardware camera button click
This commit is contained in:
		| @@ -46,5 +46,15 @@ | |||||||
|             android:name=".AboutActivity" |             android:name=".AboutActivity" | ||||||
|             android:label="@string/about" |             android:label="@string/about" | ||||||
|             android:screenOrientation="portrait"/> |             android:screenOrientation="portrait"/> | ||||||
|  |  | ||||||
|  |         <receiver | ||||||
|  |             android:name=".HardwareShutterReceiver" | ||||||
|  |             android:enabled="true" | ||||||
|  |             android:exported="true"> | ||||||
|  |             <intent-filter android:priority="999"> | ||||||
|  |                 <action android:name="android.intent.action.CAMERA_BUTTON"/> | ||||||
|  |                 <category android:name="android.intent.category.DEFAULT"/> | ||||||
|  |             </intent-filter> | ||||||
|  |         </receiver> | ||||||
|     </application> |     </application> | ||||||
| </manifest> | </manifest> | ||||||
|   | |||||||
| @@ -0,0 +1,15 @@ | |||||||
|  | package com.simplemobiletools.camera; | ||||||
|  |  | ||||||
|  | import android.content.BroadcastReceiver; | ||||||
|  | import android.content.Context; | ||||||
|  | import android.content.Intent; | ||||||
|  |  | ||||||
|  | public class HardwareShutterReceiver extends BroadcastReceiver { | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public void onReceive(Context context, Intent intent) { | ||||||
|  |         Intent mainIntent = new Intent(context.getApplicationContext(), MainActivity.class); | ||||||
|  |         mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); | ||||||
|  |         context.startActivity(mainIntent); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -112,7 +112,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen | |||||||
|  |  | ||||||
|     private void handleIntent() { |     private void handleIntent() { | ||||||
|         final Intent intent = getIntent(); |         final Intent intent = getIntent(); | ||||||
|         if (intent != null) { |         if (intent != null && intent.getAction() != null) { | ||||||
|             if (intent.getExtras() != null && intent.getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE)) { |             if (intent.getExtras() != null && intent.getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE)) { | ||||||
|                 isImageCaptureIntent = true; |                 isImageCaptureIntent = true; | ||||||
|                 hideToggleModeAbout(); |                 hideToggleModeAbout(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user