use of android.content.ActivityNotFoundException in project Fairphone by Kwamecorp.
the class LauncherTransitionable method onClickVoiceButton.
/**
* Event handler for the voice button
*
* @param v
* The view that was clicked.
*/
public void onClickVoiceButton(View v) {
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
try {
final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
ComponentName activityName = searchManager.getGlobalSearchActivity();
Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (activityName != null) {
intent.setPackage(activityName.getPackageName());
}
startActivity(null, intent, "onClickVoiceButton");
} catch (ActivityNotFoundException e) {
Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivitySafely(null, intent, "onClickVoiceButton");
}
}
use of android.content.ActivityNotFoundException in project Fairphone by Kwamecorp.
the class LauncherTransitionable method startActivityForResultSafely.
void startActivityForResultSafely(Intent intent, int requestCode) {
ComponentName component = intent != null ? intent.getComponent() : null;
String packageName = intent != null ? ItemInfo.getPackageName(intent) : "implicit Intent.";
Log.d(TAG, "Start Activity for Result > " + (component != null ? component.toString() : packageName));
try {
startActivityForResult(intent, requestCode);
if (component != null && (requestCode != REQUEST_CREATE_APPWIDGET && requestCode != REQUEST_BIND_APPWIDGET)) {
updateActivityInfoViaExplicitIntent(component);
}
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
} catch (SecurityException e) {
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
Log.e(TAG, "Launcher does not have the permission to launch " + intent + ". Make sure to create a MAIN intent-filter for the corresponding activity " + "or use the exported attribute for this activity.", e);
}
}
use of android.content.ActivityNotFoundException in project Fairphone by Kwamecorp.
the class LauncherTransitionable method startGlobalSearch.
/**
* Starts the global search activity. This code is a copied from
* SearchManager
*/
public void startGlobalSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds) {
final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
if (globalSearchActivity == null) {
Log.w(TAG, "No global search activity found.");
return;
}
Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(globalSearchActivity);
// Make sure that we have a Bundle to put source in
if (appSearchData == null) {
appSearchData = new Bundle();
} else {
appSearchData = new Bundle(appSearchData);
}
// set already.
if (!appSearchData.containsKey("source")) {
appSearchData.putString("source", getPackageName());
}
intent.putExtra(SearchManager.APP_DATA, appSearchData);
if (!TextUtils.isEmpty(initialQuery)) {
intent.putExtra(SearchManager.QUERY, initialQuery);
}
if (selectInitialQuery) {
intent.putExtra(SearchManager.EXTRA_SELECT_QUERY, selectInitialQuery);
}
intent.setSourceBounds(sourceBounds);
try {
startActivity(intent);
} catch (ActivityNotFoundException ex) {
Log.e(TAG, "Global search activity not found: " + globalSearchActivity);
}
}
use of android.content.ActivityNotFoundException in project 9GAG by Mixiaoxiao.
the class IntentUtil method shareBitmap.
public static void shareBitmap(final Activity context, final Bitmap bitmap, final String chooserDialogTitleString) {
// chooserDialogTitleString = "share";
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
if (bitmap != null) {
// bitmap.compress(CompressFormat.PNG, 100, bos);
// intent.putExtra(Intent.EXTRA_STREAM, bos.toByteArray());
// final ProgressDialog dialog = ProgressDialog.show(context, null, MxxTextUtil.getTypefaceSpannableString(context, "Just wait a moment...", MxxTextUtil.Roboto_Light, false));
final Dialog dialog = MxxDialogUtil.creatPorgressDialog(context, null, MxxTextUtil.getTypefaceSpannableString(context, "Just wait a moment...", MxxTextUtil.Roboto_Light, false), false, true, null);
dialog.show();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
final String imagePath = MxxFileUtil.getCachePath(context) + "/9gag_image_share.png";
final boolean saved = BitmapUtil.saveBitmapFile(bitmap, imagePath);
context.runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.dismiss();
if (saved) {
File f = new File(imagePath);
if (f != null && f.exists() && f.isFile()) {
Uri u = Uri.fromFile(f);
intent.putExtra(Intent.EXTRA_STREAM, u);
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
context.startActivity(Intent.createChooser(intent, MxxTextUtil.getTypefaceSpannableString(context, chooserDialogTitleString, true)));
} catch (ActivityNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
}
}).start();
}
}
use of android.content.ActivityNotFoundException in project cornerstone by Onskreen.
the class PhoneWindowManager method launchAssistAction.
private void launchAssistAction() {
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
Intent intent = SearchManager.getAssistIntent(mContext);
if (intent != null) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
mContext.startActivity(intent);
} catch (ActivityNotFoundException e) {
Slog.w(TAG, "No activity to handle assist action.", e);
}
}
}
Aggregations