How to open another activity after scanning a QR code? - android

I'm currently working on QR code scanner. I want to ask if it is possible to open another activity after the QR code have been scanned rather than getting it displayed as a toast?
I've solved the problem already .Thank you guys, I'm sorry for asking for such a simple question. I'm really new to android programming.
public void scanResult(ScanResult result) {
Toast.makeText(this, result.getRawResult().getText(), Toast.LENGTH_LONG).show();
}

Why not? What seems to be the problem? In which file is your scanResult located/ do you have access to the Context?
As normal just use
Intent intent = new Intent(MyActivity.this, StartThisActivity.class);
startActivity(intent);

Related

Tts share android studio

can someone help-me with this? I made an "tts app" that speak what de users enter in a textfield. But now i want to share this tts but i can't, I need made casting for the tts to an mp3 or some like this before sharing? An if yes, how can I do it? Thanks.
Here is the code to share:
private void shareAudio()
{
Bundle bundle = new Bundle();
Intent intent = new Intent( Intent.ACTION_SEND );
intent.setType("audio/3gpp");
startActivity( intent );
}
PS: I seem one or two questions with the same problem but i really don't understand.

Get Results from zxing - directly integrated in Android

im new to all the programming stuff so please forgive me If my question is rather stupid ;)
I integrated zxing directly as a library and now im trying to scan some QR Codes and get the result. But sadly I have no idea how to get it.
I found some hints that it works with "onActivityResult(int requestCode, int resultCode, Intent intent) "and for that i have to declare a new intent like this
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
But if I copy this code to my app, it will always try to open a thirdparty app. Thats exactly what i dont want.
Im sure my mistake is very obvious, but I dont see it ;) Would be happy about every help.
If I'm not getting you wrong, you want to display ZXing natively.
To do that please follow this tutorial
http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/
In case of any doubt please let me know.
Regards.

Android camera intent confusion

I am working on an app in which i have to click a pic a pic and save it to a specified folder. I am using android.provider.MediaStore.ACTION_IMAGE_CAPTURE in intent to invoke the camera .I am done with coding and my activity is working fine.But now i have a question in my mind that whether i should stick with this code or i should use the code given here.Need your precious suggestions on this topic.
Thanx in advance.
If you want to just click a picture and save it to a specified folder nothing more then You can use Intent and call ACTION_IMAGE_CAPTURE, it easy to let handle on camera activity do your stuff,
And If your application has some serious deep work with camera when you want to modify preview screen size, and all those things,(For this you have to handle all things like to manage camera, and when to release it, check for don't freeze main UI..) then you have to go with the code you suggested...
Choice is yours.....
I suggest you use the code from your link.
Because most of the stock camera apps don't work as expected with Image Capture. For example the Galaxy S2 and most other Samsung and HTC phones give you the picture bytes back and also save the picture in the standard DCIM Folder on SD-Card, if you want it or not.
public void imageFromCamera() {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
Log.d(TAG, "No SDCARD");
} else {
mImageFile = new File(Environment.getExternalStorageDirectory()+File.separator+"MyApp",
"PIC"+System.currentTimeMillis()+".jpg");
mTempImagePath = mImageFile.getAbsolutePath();
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mImageFile));
startActivityForResult(intent, TAKE_PICTURE);
}
}
this what u r searching i am thinking..

How to get information by bar code?

I'm a new android developer, and I try to create an app for using bar code. I try ZXing, it is very easy. But now I need get information about product by bar code. How can I do that?
You'll need to use some kind of web service to look up the product information associated with an UPC/EAN code using for example an AsyncTask. A quick Google search turned up the Internet UPC Database.
Here's a sample record of what data they provide: http://www.upcdatabase.com/item/0081697521221
Please carefully read their ToS: http://www.upcdatabase.com/docs/terms.asp
To use one dimensional barcodes use PRODUCT_MODE.
If you want to be able to scan them all don't set anything in extras scan_mode.
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.setPackage("com.google.zxing.client.android");
//intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);
Bar code gives you nothing but a number (product number). You need to have a web service where you can send this number to get more details.
you have to call the barcode reader by intent, then the user scans the barcode(if they have the barcode reader installed), and the barcode reader sends the data to your app
here's the code on how to do it.
http://code.google.com/p/zxing/wiki/ScanningViaIntent
as you can see in public void onActivityResult
these are the data returned by the scanner
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

Barcode scanner app in zxing

I have posted a question before and got response regarding Barcode scanning in ZXing.
Currently i have run the barcode scanner app code, that is given in the source(/android/) using this post
My objective is to scan a barcode in my app. Since zxing is open source as told by the authors, i need to customize the scanner app raw code in my app. I found many files like WifiActivity and all. I dont know whether all the files are required to scan a barcode.
Now i want to extract the necessary and required files to decode using the camera captured image. Is it possible to extract the parts? If yes, can anyone help me in doing this by referring any links or steps. Thanks for all your useful posts and great responses. Sorry for my bad english.
what exactly are you trying to achieve? Do you want to edit and enhance the ZXing Source/App or want to use this library in your App for scanning.
For scanning you could invoke the activity for the scan result like following:
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
try {
startActivityForResult(intent, REQUEST_CODE);
} catch (ActivityNotFoundException e) {
//Do something here
}
After scan u will receive the result in onActivityResult method:
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == REQUEST_CODE) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}
I did something similar to this, but I only wanted the QR generation part of the zxing project. So I found the relevant call (maybe something like Bitmap b = zx.genQRCode() or whatever) and copied that java file into my project.
Compile and BAM - you get a ton of compile errors. At the point you just start copying other referenced files into your project until you don't get any more compile errors.
Don't forget to include proper attribution in your app - see this FAQ.

Categories

Resources