Example usage for android.app Activity getLocalClassName

List of usage examples for android.app Activity getLocalClassName

Introduction

In this page you can find the example usage for android.app Activity getLocalClassName.

Prototype

@NonNull
public String getLocalClassName() 

Source Link

Document

Returns class name for this activity with the package prefix removed.

Usage

From source file:Main.java

/** Launch an email intent if the device is capable.
 *
 * @param activity The parent activity (for context)
 * @param addr The address to email (not the full URI)
 * @param text The email body// w  ww  . j  av  a2 s .co m
 */
public static void launchEmailIntent(final Activity activity, String addr, String text) {
    Log.i(LOG_TAG, "Launch email intent from " + activity.getLocalClassName());
    // create email intent
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { addr });
    emailIntent.setType("text/plain");
    // make sure there is an activity which can handle the intent.
    PackageManager emailpackageManager = activity.getPackageManager();
    List<ResolveInfo> emailresolveInfos = emailpackageManager.queryIntentActivities(emailIntent, 0);
    if (emailresolveInfos.size() > 0) {
        activity.startActivity(emailIntent);
    }
}

From source file:com.amazon.analytics.AnalyticsManager.java

/**
 * Get Activity name, static internal method.
 *
 * @param activity Activity reference.//from  w w  w.  ja v  a  2  s  .com
 * @return Name of the Activity.
 */
private static String getActivityName(Activity activity) {

    String activityName = activity.getLocalClassName();
    return getExtension(activityName);
}

From source file:com.amazon.android.navigator.Navigator.java

/**
 * {@inheritDoc}//from w ww  .ja  v  a 2 s  . c o m
 */
private static String getActivityName(Activity activity) {

    return StringManipulation.getExtension(activity.getLocalClassName());
}

From source file:at.wada811.android.library.demos.app.TabFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    if (activity instanceof TabFragmentCallbackProvider == false) {
        throw new ClassCastException(activity.getLocalClassName() + " must implements "
                + TabFragmentCallbackProvider.class.getSimpleName());
    }/*from ww  w.  j a  v a  2  s .co m*/
    TabFragmentCallbackProvider provider = (TabFragmentCallbackProvider) activity;
    mCallback = provider.getTabCallback();
    mCallback.onAttach(this);
}

From source file:io.selendroid.server.model.SelendroidNativeDriver.java

public String getCurrentUrl() {
    Activity activity = serverInstrumentation.getCurrentActivity();
    if (activity == null) {
        return null;
    }//from  www  . j a v  a 2s .  co m
    return "and-activity://" + activity.getLocalClassName();
}

From source file:ca.farrelltonsolar.classic.MonitorApplication.java

@Override
public void onActivityPaused(Activity activity) {
    if (activity.getLocalClassName().compareTo("MonitorActivity") == 0) {
        LocalBroadcastManager.getInstance(this).unregisterReceiver(addChargeControllerReceiver);
        LocalBroadcastManager.getInstance(this).unregisterReceiver(removeChargeControllerReceiver);
    }/*from   w  ww .j a  va2s.c om*/
}

From source file:ca.farrelltonsolar.classic.MonitorApplication.java

@Override
public void onActivityResumed(Activity activity) {
    if (activity.getLocalClassName().compareTo("MonitorActivity") == 0) {
        LocalBroadcastManager.getInstance(this).registerReceiver(addChargeControllerReceiver,
                new IntentFilter(Constants.CA_FARRELLTONSOLAR_CLASSIC_ADD_CHARGE_CONTROLLER));
        LocalBroadcastManager.getInstance(this).registerReceiver(removeChargeControllerReceiver,
                new IntentFilter(Constants.CA_FARRELLTONSOLAR_CLASSIC_REMOVE_CHARGE_CONTROLLER));
    }/* w w  w . ja v  a  2  s. co  m*/
}

From source file:at.wada811.imageslider.ImageSliderFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    if (activity instanceof ImageSliderFragmentCallbackProvider == false) {
        throw new ClassCastException(activity.getLocalClassName() + " must implements "
                + ImageSliderFragmentCallbackProvider.class.getSimpleName());
    }/*from   ww w  . j  a va  2 s  .c  om*/
    ImageSliderFragmentCallbackProvider provider = (ImageSliderFragmentCallbackProvider) activity;
    mCallback = provider.getImageSliderCallback();
}

From source file:at.wada811.imageslider.DebugFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    if (activity instanceof DebugFragmentCallbackProvider == false) {
        throw new ClassCastException(activity.getLocalClassName() + " must implements "
                + DebugFragmentCallbackProvider.class.getSimpleName());
    }// ww  w .j  a  va  2  s  . c om
    DebugFragmentCallbackProvider provider = (DebugFragmentCallbackProvider) activity;
    mCallback = provider.getDebugCallback();
}

From source file:org.linphone.purchase.InAppPurchaseHelper.java

public InAppPurchaseHelper(Activity context, InAppPurchaseListener listener) {
    mContext = context;//from   w  ww  .  j a  v a2s .  c o m
    mListener = listener;
    mGmailAccount = getGmailAccount();

    Log.d("[In-app purchase] creating InAppPurchaseHelper for context " + context.getLocalClassName());

    mServiceConn = new ServiceConnection() {
        @Override
        public void onServiceDisconnected(ComponentName name) {
            Log.d("[In-app purchase] onServiceDisconnected!");
            mService = null;
        }

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            Log.d("[In-app purchase] onServiceConnected!");
            mService = IInAppBillingService.Stub.asInterface(service);
            String packageName = mContext.getPackageName();
            try {
                int response = mService.isBillingSupported(API_VERSION, packageName, ITEM_TYPE_SUBS);
                if (response != RESPONSE_RESULT_OK || mGmailAccount == null) {
                    Log.e("[In-app purchase] Error: Subscriptions aren't supported!");
                    mListener.onError(CLIENT_ERROR_SUBSCRIPTION_PURCHASE_NOT_AVAILABLE);
                } else {
                    mListener.onServiceAvailableForQueries();
                }
            } catch (RemoteException e) {
                Log.e(e);
            }
        }
    };

    Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    serviceIntent.setPackage("com.android.vending");
    if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) {
        boolean ok = mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
        if (!ok) {
            Log.e("[In-app purchase] Error: Bind service failed");
            mListener.onError(CLIENT_ERROR_BIND_TO_BILLING_SERVICE_FAILED);
        }
    } else {
        Log.e("[In-app purchase] Error: Billing service unavailable on device.");
        mListener.onError(CLIENT_ERROR_BILLING_SERVICE_UNAVAILABLE);
    }
}