use of android.content.ActivityNotFoundException in project FloatingSearchView by renaudcerrato.
the class PackageUtils method startTextToSpeech.
public static void startTextToSpeech(Activity context, String prompt, int requestCode) {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
try {
context.startActivityForResult(intent, requestCode);
} catch (ActivityNotFoundException a) {
Toast.makeText(context, context.getString(R.string.speech_not_supported), Toast.LENGTH_SHORT).show();
}
}
use of android.content.ActivityNotFoundException in project cw-omnibus by commonsguy.
the class MainActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CONTENT_REQUEST) {
if (resultCode == RESULT_OK) {
Intent i = new Intent(Intent.ACTION_VIEW);
Uri outputUri = FileProvider.getUriForFile(this, AUTHORITY, output);
i.setDataAndType(outputUri, "image/jpeg");
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
startActivity(i);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.msg_no_viewer, Toast.LENGTH_LONG).show();
}
finish();
}
}
}
use of android.content.ActivityNotFoundException in project cw-omnibus by commonsguy.
the class SearchView method onVoiceClicked.
private void onVoiceClicked() {
// guard against possible race conditions
if (mSearchable == null) {
return;
}
SearchableInfo searchable = mSearchable;
try {
if (searchable.getVoiceSearchLaunchWebSearch()) {
Intent webSearchIntent = createVoiceWebSearchIntent(mVoiceWebSearchIntent, searchable);
getContext().startActivity(webSearchIntent);
} else if (searchable.getVoiceSearchLaunchRecognizer()) {
Intent appSearchIntent = createVoiceAppSearchIntent(mVoiceAppSearchIntent, searchable);
getContext().startActivity(appSearchIntent);
}
} catch (ActivityNotFoundException e) {
// Should not happen, since we check the availability of
// voice search before showing the button. But just in case...
Log.w(LOG_TAG, "Could not find voice search activity");
}
}
use of android.content.ActivityNotFoundException in project GeekNews by codeestX.
the class AlipayUtil method startIntentUrl.
/**
* 打开 Intent Scheme Url
*
* @param activity Parent Activity
* @param intentFullUrl Intent 跳转地址
* @return 是否成功调用
*/
public static boolean startIntentUrl(Activity activity, String intentFullUrl) {
try {
Intent intent = Intent.parseUri(intentFullUrl, Intent.URI_INTENT_SCHEME);
activity.startActivity(intent);
return true;
} catch (URISyntaxException e) {
e.printStackTrace();
return false;
} catch (ActivityNotFoundException e) {
e.printStackTrace();
return false;
}
}
use of android.content.ActivityNotFoundException in project android by cSploit.
the class PortScanner method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
Boolean isDark = themePrefs.getBoolean("isDark", false);
if (isDark)
setTheme(R.style.DarkTheme);
else
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
mPreferences = System.getSettings();
mTextDoc = (TextView) findViewById(R.id.scanDoc);
mTextParameters = (EditText) findViewById(R.id.scanParameters);
mScanFloatingActionButton = (FloatingActionButton) findViewById(R.id.scanToggleButton);
mScanProgress = (ProgressBar) findViewById(R.id.scanActivity);
mShowCustomParameters = mPreferences.getBoolean(CUSTOM_PARAMETERS, false);
if (mShowCustomParameters)
displayParametersField();
else
hideParametersField();
mScanFloatingActionButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mRunning) {
setStoppedState();
} else {
setStartedState();
}
}
});
ListView mScanList = (ListView) findViewById(R.id.scanListView);
createPortList();
final Target target = System.getCurrentTarget();
final String cmdlineRep = target.getCommandLineRepresentation();
mScanReceiver = new Receiver(target);
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mPortList);
mScanList.setAdapter(mListAdapter);
mScanList.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
int portNumber = target.getOpenPorts().get(position).getNumber();
if (!urlFormats.containsKey(portNumber)) {
portNumber = 0;
}
final String url = String.format(urlFormats.get(portNumber), cmdlineRep, portNumber);
new ConfirmDialog("Open", "Open " + url + " ?", PortScanner.this, new ConfirmDialogListener() {
@Override
public void onConfirm() {
try {
Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
PortScanner.this.startActivity(browser);
} catch (ActivityNotFoundException e) {
System.errorLogging(e);
new ErrorDialog(getString(R.string.error), getString(R.string.no_activities_for_url), PortScanner.this).show();
}
}
@Override
public void onCancel() {
}
}).show();
return false;
}
});
}
Aggregations