Search in sources :

Example 26 with Activity

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;
}
Also used : Activity(android.app.Activity) ProgressDialog(android.app.ProgressDialog)

Example 27 with Activity

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();
}
Also used : AlertDialog(android.app.AlertDialog) Activity(android.app.Activity)

Example 28 with Activity

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();
}
Also used : Activity(android.app.Activity)

Example 29 with Activity

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;
}
Also used : Activity(android.app.Activity)

Example 30 with Activity

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();
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) Intent(android.content.Intent) PackageManager(android.content.pm.PackageManager) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) Resources(android.content.res.Resources)

Aggregations

Activity (android.app.Activity)1138 View (android.view.View)200 Test (org.junit.Test)166 Intent (android.content.Intent)162 TextView (android.widget.TextView)83 ArrayList (java.util.ArrayList)62 Bundle (android.os.Bundle)53 Context (android.content.Context)51 ViewGroup (android.view.ViewGroup)48 DialogInterface (android.content.DialogInterface)44 AlertDialog (android.app.AlertDialog)41 Robolectric.buildActivity (org.robolectric.Robolectric.buildActivity)40 ImageView (android.widget.ImageView)36 Twitter (twitter4j.Twitter)35 LayoutInflater (android.view.LayoutInflater)34 AppCompatActivity (android.support.v7.app.AppCompatActivity)32 DisplayMetrics (android.util.DisplayMetrics)32 FrameLayout (android.widget.FrameLayout)28 Robolectric.setupActivity (org.robolectric.Robolectric.setupActivity)28 FragmentActivity (android.support.v4.app.FragmentActivity)27