android - Zxing QR Reader doesn't take focus again -
i have made app using zxing library qr reader.
my problem is when scan activity starts takes focus of whatever in view finder , refuses take focus again if placed on else. please help.
main class
public class main extends activity { final context context = this; final activity activity = this; button scanbutton; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); scanbutton = (button) findviewbyid(r.id.button1); scanbutton.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub intent intent = new intent( "com.google.zxing.client.android.scan"); intent.putextra("scan_mode", "qr_code_mode"); startactivityforresult(intent, 0); // intentintegrator integrator = new intentintegrator(activity); // integrator.initiatescan(); } }); } public void onactivityresult(int requestcode, int resultcode, intent intent) { // intentresult scanresult = // intentintegrator.parseactivityresult(requestcode, resultcode, // intent); // if (scanresult != null) { // handle scan result // string contents=scanresult.getcontents(); // } if (requestcode == 0) { if (resultcode == result_ok) { string contents = intent.getstringextra("scan_result"); string format = intent.getstringextra("scan_result_format"); // handle successful scan alertdialog.builder alertdialogbuilder = new alertdialog.builder( context); alertdialogbuilder.settitle("scan result"); // set dialog message alertdialogbuilder.setmessage(contents).setpositivebutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { // if button clicked, // close // current activity dialog.cancel(); } }); // create alert dialog alertdialog alertdialog = alertdialogbuilder.create(); // show alertdialog.show(); } else if (resultcode == result_canceled) { // handle cancel } } } }
manifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.scanner.demo" android:versioncode="1" android:versionname="1.0"> <uses-permission android:name="android.permission.camera" /> <application android:icon="@drawable/launch_icon" android:label="@string/app_name"> <activity android:name=".main" android:label="@string/app_name" android:configchanges="orientation|keyboardhidden"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <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> </application> </manifest>
i need camera take focus again after time. make necessary changes ?
Comments
Post a Comment