launch the app on Hardware camera button click

This commit is contained in:
tibbi 2016-06-18 00:12:58 +02:00
parent 56c05cb737
commit bc3af7e6bc
3 changed files with 26 additions and 1 deletions

View File

@ -46,5 +46,15 @@
android:name=".AboutActivity"
android:label="@string/about"
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>
</manifest>

View File

@ -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);
}
}

View File

@ -112,7 +112,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
private void handleIntent() {
final Intent intent = getIntent();
if (intent != null) {
if (intent != null && intent.getAction() != null) {
if (intent.getExtras() != null && intent.getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE)) {
isImageCaptureIntent = true;
hideToggleModeAbout();