Android TAKE_PHOTO_WITH_DATA cannot be resolved to a variable - android

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent,TAKE_PHOTO_WITH_DATA);
Hi all,I got two questions.
the code above show an "TAKE_PHOTO_WITH_DATA cannot be resolved to a variable" error,
I use sdk 2.2.3 but change to 4.2.2 the error still there,
what's wrong with "TAKE_PHOTO_WITH_DATA"?
by the way,
Is there any "TAKE_VIDEO_WITH_DATA" or "TAKE_SOUND_WITH_DATA" can use?
thanks a lot.

It will show an error as long as you don't declare the particular variable,TAKE_PHOTO_WITH_DATA is nothing but a request code,you can even use an integer directly instead of this like startActivityForResult(intent,1); it is just for checking the results you can read more about request codes in the android developer site

Related

Android Google Translate QuickTranslateActiviy - Intent extra issue

I want to use the QuickTranslateActiviy
and I have tried this
Intent i = new Intent();
i.setAction(Intent.ACTION_PROCESS_TEXT);
i.addCategory(Intent.CATEGORY_DEFAULT);
i.putExtra(Intent.EXTRA_TEXT,"String");
i.setType(ClipDescription.MIMETYPE_TEXT_PLAIN);
i.setComponent(new ComponentName("com.google.android.apps.translate","com.google.android.apps.translate.QuickTranslateActivity"));
startActivity(i);
and It just keep showing the toast that could not find text.
But the manifest of the Google translate here show that it accept plain text
had anyone try that before?Or am I doing it in a wrong way?
Tactically, you are using the wrong extra name. It should be EXTRA_PROCESS_TEXT or EXTRA_PROCESS_TEXT_READONLY, not EXTRA_TEXT.
Strategically, your implementation will break any time that the Google Translate app refactors their code or otherwise changes the fully-qualified class name of the activity.

how to use the intent anchor to launch my app with extra data(parameters) in android

I have ever tried to launch my app using URI schema in javascript like this:
window.location = "myapp://api/image?imageurl=hogehoge"
but it failed in android.I don't know why. it's ok in iphone...
so I changed to use the intent anchor to launch my app in android as described here. I'm able to get it to launch my app using this syntax,
<a href="intent://#Intent;scheme=http;package=com.example.myapp;end">Launch my app</>
but if I use the intent anchor , how can I pass the extra data ("api/image?imageurl=hogehoge") ?
maybe i can add "S.imageurl=hogehoge" to the href but how can i pass this →"api/image?"
Try something like this:
Launch my app

Android: Open pdf file with the specified software

Now I have downloaded a .pdf file from website and wanna open it with the specified software like "Adobe Reader".How can I achieve this?
You cant. All you can do is fire off an intent and let the system handle it. If the user already has a default app that they've chosen to handle PDFs, that's the one that will open the PDF.
In general it's something like:
File file = new File("/sdcard/example.pdf");
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
} .......
I have solved this problem by adding the method "Intent.setComponent(pkg,cls);".
PS: I don Not angry about downing my reps.And thank you for giving me the suggestions.
PSS: What I wanna say is "Not everyone will get the same apple." I post this question for I have this problem and it occured in Android App.And Someone told me "Cannot".I post my answer just to tell you Ive solved this(or just mine) problem,and maybe it will help someone who has the problem same as mine.Yeah,this answer may make no sense to you.
PSSS::-)But I still think the API make sense to me and to its Designer.
*PSSSS:*At last,thank you all.And forgive my poor English.
You should first have a look at the intents filters documentation. Then you can start an intent (after adding the intent filter) for your PDF file.

Error installing apk programmatically: "android.content.ActivityNotFoundException: Unable to find explicit activity class"

I am trying the following code to install apk file saved on the SD Card and getting following exception: "android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.packageinstaller/.PackageInstallerActivity}". In the code, file is representing the apk file's SD Card path.
Intent resultIntent = new Intent(android.content.Intent.ACTION_VIEW);
resultIntent.setDataAndType(Uri.fromFile(file),"application/vnd.android.package-archive");
resultIntent.setClassName("com.android.packageinstaller", ".PackageInstallerActivity");
startActivity(resultIntent);
How do I manage this?
You might want to read this blog post on how to install and remove packages using the PackageInstaller.
Note that since the package installer is registered to handle the MIME type application/vnd.android.package-archive, you shouldn't have to specify the intent class name explicitly; the intent resolver should find the right one to start.
Also, the operation will succeed only if the user has enabled INSTALL_NON_MARKET_APPS. This is directly related to the failure you are seeing, but it's something to keep in mind as you'll likely run into that as well.
Try to add the Intent.FLAG_ACTIVITY_NEW_TASK like so:
Intent resultIntent = new Intent();
resultIntent.setAction(Intent.ACTION_VIEW);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
resultIntent.setDataAndType(Uri.fromFile(file),"application/vnd.android.package-archive");
And then call
startActivity(resultIntent);
NOTE! that the condition regarding INSTALL_NON_MARKET_APPS, as mentioned earlier by Franci Penov, still must be valid!

how to call the google map from my android application like invoke the email

try {
Intent searchAddress = new Intent(Intent.ACTION_VIEW,
Uri.parse("geo:0,0?="+emp_city_location));
startActivity(searchAddress);
} catch(Exception e) {
System.out.println(e);
}
i got the exception like
03-03 21:01:56.349: INFO/System.out(179): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=geo:0,0?=chennai }
please do reply me
You need to construct your geo: URL properly. See the documentation for the syntax. I think you may only be missing a q between the ? and the =, but I have not tried that particular geo: syntax.
Make sure that you are using the Google API emulator image for your testing. Bring up the AVD and set the emulator to be a Google API emulator. If you don't do this, then you will continue to get the bug. Also, the previous poster was right... you need to following the URI standards found here: http://developer.android.com/intl/de/guide/appendix/g-app-intents.html
Regards,
Chris
Have declared Activity in manifest file also check have you added Google map library in manifest file
Try something like this :
geo:0,0?q=chennai

Categories

Resources