I'm new to android developement and I'm trying to use zxing to my google glass application, and it scans successfully. However when I'm tapping the glass for the result, nothing happens. But, when I'm swiping it down the activity is closing and execute the code in RESULT_CANCEL option in onActivityResult. That's why I'm confuse.
Am I getting the result back to my activity or not? I reasearched a lot and I tried different solutions but nothing works.
This is my code:
Main Activity
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
scan();
setContentView(R.layout.activity_main);
}
private void scan(){
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
Toast.makeText(getApplicationContext(), contents + format, Toast.LENGTH_LONG).show();
// Handle successful scan
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
Log.i("App","Scan unsuccessful");
}
}
Manifest:
<activity
android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
I'am missing something? Any help would be much appreeiated.