use of android.app.Activity in project android_frameworks_base by ParanoidAndroid.
the class KeyguardSimPukView method getSimUnlockProgressDialog.
private Dialog getSimUnlockProgressDialog() {
if (mSimUnlockProgressDialog == null) {
mSimUnlockProgressDialog = new ProgressDialog(mContext);
mSimUnlockProgressDialog.setMessage(mContext.getString(R.string.kg_sim_unlock_progress_dialog_message));
mSimUnlockProgressDialog.setIndeterminate(true);
mSimUnlockProgressDialog.setCancelable(false);
if (!(mContext instanceof Activity)) {
mSimUnlockProgressDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
}
}
return mSimUnlockProgressDialog;
}
use of android.app.Activity in project android_frameworks_base by ParanoidAndroid.
the class KeyguardHostView method showDialog.
private void showDialog(String title, String message) {
final AlertDialog dialog = new AlertDialog.Builder(mContext).setTitle(title).setMessage(message).setNeutralButton(com.android.internal.R.string.ok, null).create();
if (!(mContext instanceof Activity)) {
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
}
dialog.show();
}
use of android.app.Activity in project android_frameworks_base by ParanoidAndroid.
the class ActivityInstrumentationTestCase2 method tearDown.
@Override
protected void tearDown() throws Exception {
// Finish the Activity off (unless was never launched anyway)
Activity a = super.getActivity();
if (a != null) {
a.finish();
setActivity(null);
}
// Scrub out members - protects against memory leaks in the case where someone
// creates a non-static inner class (thus referencing the test case) and gives it to
// someone else to hold onto
scrubClass(ActivityInstrumentationTestCase2.class);
super.tearDown();
}
use of android.app.Activity in project android_frameworks_base by ParanoidAndroid.
the class ActivityInstrumentationTestCase2 method getActivity.
/**
* Get the Activity under test, starting it if necessary.
*
* For each test method invocation, the Activity will not actually be created until the first
* time this method is called.
*
* <p>If you wish to provide custom setup values to your Activity, you may call
* {@link #setActivityIntent(Intent)} and/or {@link #setActivityInitialTouchMode(boolean)}
* before your first call to getActivity(). Calling them after your Activity has
* started will have no effect.
*
* <p><b>NOTE:</b> Activities under test may not be started from within the UI thread.
* If your test method is annotated with {@link android.test.UiThreadTest}, then your Activity
* will be started automatically just before your test method is run. You still call this
* method in order to get the Activity under test.
*
* @return the Activity under test
*/
@Override
public T getActivity() {
Activity a = super.getActivity();
if (a == null) {
// set initial touch mode
getInstrumentation().setInTouchMode(mInitialTouchMode);
final String targetPackage = getInstrumentation().getTargetContext().getPackageName();
// inject custom intent, if provided
if (mActivityIntent == null) {
a = launchActivity(targetPackage, mActivityClass, null);
} else {
a = launchActivityWithIntent(targetPackage, mActivityClass, mActivityIntent);
}
setActivity(a);
}
return (T) a;
}
use of android.app.Activity in project android_frameworks_base by ParanoidAndroid.
the class VersionDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Activity activity = getActivity();
// Need to use our library's resources for showing the dialog.
final Context context;
try {
context = activity.createPackageContext(SharedLibraryMain.LIBRARY_PACKAGE, 0);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalStateException("Can't find my package!", e);
}
final Resources res = context.getResources();
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(res.getText(R.string.upgrade_title));
builder.setMessage(res.getString(R.string.upgrade_body, activity.getApplicationInfo().loadLabel(activity.getPackageManager()), context.getApplicationInfo().loadLabel(context.getPackageManager())));
builder.setPositiveButton(res.getText(R.string.upgrade_button), new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Launch play store into the details of our app.
try {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + SharedLibraryMain.LIBRARY_PACKAGE)));
} catch (android.content.ActivityNotFoundException anfe) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + SharedLibraryMain.LIBRARY_PACKAGE)));
}
}
});
return builder.create();
}
Aggregations