how to create Intent.ACTION_CALL_PRIVILEGED from code in android? - android

I was following this post to create a call. I know I can use ACTION_CALL/ACTION_DIAL but they will not meet my need. It suggested that I need to use #hide annotation. I was wondering how to do that.
(sdk 2.2) When I put the following code in eclipse shows red mark under Intent.ACTION_CALL_PRIVILEGED.
Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
Uri.fromParts("tel", number, null)); startActivity(intent);

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.

Links in Sony Smartwatch 2

I want to show an image in my Sony Smarwatch Sample project. How can I add a link to an external URL? The URL has to be shown in my device not in the SmartWatch. My code is the following, with this my image is shown in the layout:
Bundle iconBundle = new Bundle();
iconBundle.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.thumbnail);
iconBundle.putString(Control.Intents.EXTRA_DATA_URI,
ExtensionUtils.getUriString(mContext, R.drawable.thumbnail_list_item));
¿How can I add a event to this bundle? I want to go to an external url. How can I add a link to my Preference Class?
I am not totally sure I understand what you are asking, but if you want to be able to click on something on the watch and have it launch a url you can use this code:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/developer?id=Sony+Mobile+Communications"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctxt.startActivity(intent);
If you want to launch the preference settings screen for your app you can do something like this:
Intent intent = new Intent(ctxt, HelloLayoutsPreferenceActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctxt.startActivity(intent);
This should work in the Hello Layouts sample project. The context is passed in the control extension constructor so you should be able to grab it from there. Please let me know if this is not what you were asking.

Why doesn't my App Chooser dialogue show?

I am using this tutorial to learn about the basics of Intents in Android. The code sample I am using is adopted from the section named "Force an App Chooser" on the page linked.
The following is the method which should be invoked on the click of the button.
public void startSecondActivity(View view) {
Intent intent = new Intent(Intent.ACTION_SEND);
String fileChooserLabel = getResources().getString(R.string.fileChooserLabel);
Intent fileChooserIntent = Intent.createChooser(intent, fileChooserLabel);
if (intent.resolveActivity(getPackageManager())!=null) {
startActivity(intent);
} else {
textView = (TextView) findViewById(R.id.text_view);
textView.setText("False");
}
}
But it just enters the else block of the if-else conditional. I tried this app on both a real device and the emulator. So can anybody point out what might be wrong here, and what I can do about it.
Note: I did not add anything to the Manifest file, since I am using Eclipse IDE and I suppose whatever is required at this point is automatically added to the manifest file.
It is returning null because there are no activities on the device that support your Intent. In this case, your ACTION_SEND Intent is not properly set up.
Note that the code sample you used as a reference is not a tutorial. It is not designed to be a complete code sample. In fact, what they list there will not even compile, as their ... is meant to be replaced by your own code to complete setting up the Intent.
You will need to fully configure your ACTION_SEND Intent, most notably setting the MIME type, as is covered elsewhere in the documentation. Replacing:
Intent intent = new Intent(Intent.ACTION_SEND);
with something like:
Intent intent = new Intent(Intent.ACTION_SEND)
.setType("text/plain")
.putExtra(Intent.EXTRA_TEXT, "IM IN UR STAK OVERFLO ANZWR");
should suffice.

Search Intent in Android (for Evernote)

I was trying to create an intent in Android that would search in the Evernote app for a specific keyword, but the documentation that the Evernote site mentions doesn't seem to be available, so I tried writing it on my own, but it doesn't seem to work. This is what I have now:
final String ACTION_EVERNOTE = "com.evernote.action.SEARCH_NOTES";
String KEYWORD = "hoi";
Intent i = new Intent();
i.setAction(ACTION_EVERNOTE);
i.putExtra(Intent.ACTION_SEARCH, KEYWORD);
startActivity(i);
Does anyone have an idea what is going wrong here? Right now it just performs a search with an asterisk, which is the default, so it probably just ignores the ACTION_SEARCH part. Is there an error in that part of my intent?
Thanks in advance!
Try it like this, with the String called QUERY, as it's called in the SearchManager documentation:
final String ACTION_EVERNOTE = "com.evernote.action.SEARCH_NOTES";
String QUERY = "hoi";
Intent i = new Intent();
i.setAction(ACTION_EVERNOTE);
i.putExtra(Intent.ACTION_SEARCH, QUERY);
startActivity(i);
An addition to the answer above. There is a new tiny library to send these Intents to the Evernote core app.
https://github.com/evernote/android-intent

Android TAKE_PHOTO_WITH_DATA cannot be resolved to a variable

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

Categories

Resources