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;
}
});
}
use of android.content.ActivityNotFoundException in project OneClickAndroid by cyngn.
the class UsbActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OneClickStats.sendEvent(this, OneClickStats.Categories.PAGE_SHOWN, OneClickStats.Actions.PAGE_ADB);
if (adbIsEnabled()) {
startActivity(new Intent(getBaseContext(), PtpActivity.class));
finish();
return;
}
setContentView(R.layout.usb);
ImageView instructionView = (ImageView) findViewById(R.id.usb_instructions);
DecelerateInterpolator interpolator = new DecelerateInterpolator(2.0f);
AnimationSet instructionAnimations = new AnimationSet(true);
instructionAnimations.setInterpolator(interpolator);
TranslateAnimation instructionMoveAnimation = new TranslateAnimation(0, 0, 250, 0);
instructionMoveAnimation.setDuration(1000);
instructionMoveAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
instructionAnimations.addAnimation(instructionMoveAnimation);
// we want them to read the instructions first! so we give them a few seconds
AlphaAnimation instructionFadeAnimation = new AlphaAnimation(0.0f, 1.0f);
instructionFadeAnimation.setDuration(1000);
instructionFadeAnimation.setStartOffset(500);
instructionFadeAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
instructionAnimations.addAnimation(instructionFadeAnimation);
instructionView.setAnimation(instructionAnimations);
// continue button should take even longer
AlphaAnimation buttonAnimation = new AlphaAnimation(0.0f, 1.0f);
buttonAnimation.setDuration(750);
buttonAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
buttonAnimation.setStartOffset(1000);
findViewById(R.id.next).setAnimation(buttonAnimation);
OnClickListener openUsbListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.DevelopmentSettings");
try {
OneClickStats.sendEvent(view.getContext(), OneClickStats.Categories.BUTTON_CLICK, OneClickStats.Actions.BTN_ADB);
startActivity(intent);
startService(new Intent(getBaseContext(), UsbDebuggingMonitorService.class));
} catch (ActivityNotFoundException e) {
// we want to know if this happens, right?
OneClickStats.sendEvent(view.getContext(), OneClickStats.Categories.SWITCH_ERROR, OneClickStats.Actions.ERR_ADB);
}
}
};
findViewById(R.id.next).setOnClickListener(openUsbListener);
}
Aggregations