Example usage for android.content Intent setClassName

List of usage examples for android.content Intent setClassName

Introduction

In this page you can find the example usage for android.content Intent setClassName.

Prototype

public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) 

Source Link

Document

Convenience for calling #setComponent with an explicit application package name and class name.

Usage

From source file:com.acdd.homelauncher.fragment.InstalledAppFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    String location = (String) parent.getAdapter().getItem(position);
    final PackageLite packageLite = ACDD.getInstance().getBundlePackageLite(location);
    if (packageLite != null) {

        AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
        //?//  w w w . jav a 2  s.c  o m
        builder.setIcon(R.mipmap.ic_launcher);
        //?
        builder.setTitle("??");
        //0: ?
        final String[] comp = new String[packageLite.components.size()];
        packageLite.components.toArray(comp);
        builder.setSingleChoiceItems(comp, 0, new AlertDialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                String className = (String) (comp[which]);
                if (!className.contains("Activity")) {
                    Toast.makeText(getActivity(), "Support Activity Only", Toast.LENGTH_SHORT).show();
                    dialog.dismiss();
                    return;
                }
                Intent mIntent = new Intent();
                mIntent.setClassName(getActivity(), className);
                startActivity(mIntent);
                dialog.dismiss();
            }
        });

        //
        builder.setPositiveButton("   ", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        //??
        builder.create().show();

    }
}

From source file:sssemil.com.wifiapmanager.MainService.java

private void showTetheredNotification() {
    if (mNotificationManager == null) {
        return;/*from w w w . j ava 2 s . c o m*/
    }

    Intent intent = new Intent();
    intent.setClassName("sssemil.com.wifiapmanager", "sssemil.com.wifiapmanager.MainActivity");
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

    PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0, null);

    CharSequence title = getText(R.string.tethered_notification_title);
    CharSequence message = getText(R.string.tethered_notification_no_device_message);

    if (mTetheredNotificationBuilder == null) {
        mTetheredNotificationBuilder = new NotificationCompat.Builder(this).setSmallIcon(mIcon);
    }

    mTetheredNotificationBuilder.setSmallIcon(mIcon).setContentTitle(title).setContentText(message)
            .setOngoing(true).setContentIntent(pi);

    mNotificationManager.notify(mIcon, mTetheredNotificationBuilder.build());
}

From source file:owne.android.envmonitor.FeaturesActivity.java

private void setupPluginsInDrawer(final ViewGroup container) {
    final LayoutInflater inflater = LayoutInflater.from(this);
    final PackageManager pm = getPackageManager();

    // look for Master Control Panel
    final Intent mcpIntent = new Intent(Intent.ACTION_MAIN);
    mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS);
    final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0);

    // configure link to Master Control Panel
    final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp);
    if (mcpInfo == null) {
        mcpItem.setTextColor(Color.GRAY);
        ColorMatrix grayscale = new ColorMatrix();
        grayscale.setSaturation(0.0f);/*  w  w  w.j  ava  2  s .  c  o m*/
        mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale));
    }
    mcpItem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            Intent action = mcpIntent;
            if (mcpInfo == null)
                action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI));
            action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            startActivity(action);
            mDrawerLayout.closeDrawers();
        }
    });

    // look for other plug-ins
    final Intent utilsIntent = new Intent(Intent.ACTION_MAIN);
    utilsIntent.addCategory(UTILS_CATEGORY);

    final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0);
    for (final ResolveInfo info : appList) {
        final View item = inflater.inflate(R.layout.drawer_plugin, container, false);
        final ImageView icon = (ImageView) item.findViewById(android.R.id.icon);
        final TextView label = (TextView) item.findViewById(android.R.id.text1);

        label.setText(info.loadLabel(pm));
        icon.setImageDrawable(info.loadIcon(pm));
        item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                final Intent intent = new Intent();
                intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(intent);
            }
        });
        container.addView(item);
    }
}

From source file:no.android.proxime.FeaturesActivity.java

private void setupPluginsInDrawer(final ViewGroup container) {
    final LayoutInflater inflater = LayoutInflater.from(this);
    final PackageManager pm = getPackageManager();

    // look for Master Control Panel
    final Intent mcpIntent = new Intent(Intent.ACTION_MAIN);
    mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS);
    final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0);

    // configure link to Master Control Panel
    final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp);
    if (mcpInfo == null) {
        mcpItem.setTextColor(Color.GRAY);
        ColorMatrix grayscale = new ColorMatrix();
        grayscale.setSaturation(0.0f);/*  www .j  a va2  s.c o  m*/
        mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale));
    }
    mcpItem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            Intent action = mcpIntent;
            if (mcpInfo == null)
                action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI));
            action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            startActivity(action);
            mDrawerLayout.closeDrawers();
        }
    });

    // look for other plug-ins
    final Intent utilsIntent = new Intent(Intent.ACTION_MAIN);
    utilsIntent.addCategory(UTILS_CATEGORY);

    final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0);
    for (final ResolveInfo info : appList) {
        final View item = inflater.inflate(R.layout.drawer_plugin, container, false);
        final ImageView icon = (ImageView) item.findViewById(android.R.id.icon);
        final TextView label = (TextView) item.findViewById(android.R.id.text1);

        label.setText(info.loadLabel(pm));
        icon.setImageDrawable(info.loadIcon(pm));
        item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                final Intent intent = new Intent();
                intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(intent);
                mDrawerLayout.closeDrawers();
            }
        });
        container.addView(item);
    }
}

From source file:com.fastbootmobile.encore.app.fragments.DspProvidersFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    DSPConnection connection = ((DspAdapter) getListAdapter()).getItem(position);
    if (connection.getConfigurationActivity() != null) {
        Intent i = new Intent();
        i.setClassName(connection.getPackage(), connection.getConfigurationActivity());
        try {//from w  w w .jav a 2 s .  co  m
            startActivity(i);
        } catch (SecurityException e) {
            Utils.shortToast(getActivity(), R.string.plugin_error);
            Log.e(TAG, "Unable to start configuration activity. Is it exported in the manifest?", e);
        } catch (ActivityNotFoundException e) {
            Utils.shortToast(getActivity(), R.string.plugin_error);
            Log.e(TAG, "Unable to start configuration activity, as the activity wasn't found", e);
        }
    } else {
        Utils.shortToast(getActivity(), R.string.no_settings_dsp);
    }
}

From source file:be.phl.mosaqua.Locator.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.locator);/*from  w  w w .j  ava2  s  . c  o m*/

    //Menu - Begin
    overridePendingTransition(R.anim.none, R.anim.none); // Change default animation

    btn_zwembad = (ImageButton) findViewById(R.id.btn_footer_zwembad);
    btn_info = (ImageButton) findViewById(R.id.btn_footer_openingsuren);
    btn_facebook = (ImageButton) findViewById(R.id.btn_footer_facebook);
    btn_locator = (ImageButton) findViewById(R.id.btn_footer_locator);

    btn_zwembad.setOnClickListener(handleButtons);
    btn_info.setOnClickListener(handleButtons);
    btn_facebook.setOnClickListener(handleButtons);
    btn_locator.setOnClickListener(handleButtons);

    mMapView = (MapView) findViewById(R.id.map);
    mMapView.onCreate(savedInstanceState);

    btn_locator.setImageResource(R.drawable.ic_menu_footer_locator_active);
    //Menu - End

    // Button Locatie linken met de layout.
    btnLocatie = (Button) findViewById(R.id.btnLocatie);

    // ClickListener voor btnLocatie
    btnLocatie.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            // Opent de applicatie Maps en toont de routebeschrijving naar
            // Mosaqua.
            String uri = "http://maps.google.com/maps?f=d&daddr=Mosaqua+Landsraderweg+11+6271+NT+Gulpen,+Nederland";
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
            intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
            startActivity(intent);

        }
    });

    setUpMapIfNeeded();

}

From source file:com.buddi.client.dfu.FeaturesActivity.java

private void setupPluginsInDrawer(final ViewGroup container) {
    final LayoutInflater inflater = LayoutInflater.from(this);
    final PackageManager pm = getPackageManager();

    // look for Master Control Panel
    final Intent mcpIntent = new Intent(Intent.ACTION_MAIN);
    mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS);
    final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0);

    // configure link to Master Control Panel
    final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp);
    if (mcpInfo == null) {
        mcpItem.setTextColor(Color.GRAY);
        ColorMatrix grayscale = new ColorMatrix();
        grayscale.setSaturation(0.0f);//  www  . j  a va2  s.  c  om
        mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale));
    }
    mcpItem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            Intent action = mcpIntent;
            if (mcpInfo == null)
                action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI));
            action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            try {
                startActivity(action);
            } catch (final ActivityNotFoundException e) {
                Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show();
            }
            mDrawerLayout.closeDrawers();
        }
    });

    // look for other plug-ins
    final Intent utilsIntent = new Intent(Intent.ACTION_MAIN);
    utilsIntent.addCategory(UTILS_CATEGORY);

    final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0);
    for (final ResolveInfo info : appList) {
        final View item = inflater.inflate(R.layout.drawer_plugin, container, false);
        final ImageView icon = (ImageView) item.findViewById(android.R.id.icon);
        final TextView label = (TextView) item.findViewById(android.R.id.text1);

        label.setText(info.loadLabel(pm));
        icon.setImageDrawable(info.loadIcon(pm));
        item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                final Intent intent = new Intent();
                intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(intent);
                mDrawerLayout.closeDrawers();
            }
        });
        container.addView(item);
    }
}

From source file:com.example.RITW.proximity.FeaturesActivity.java

private void setupPluginsInDrawer(final ViewGroup container) {
    final LayoutInflater inflater = LayoutInflater.from(this);
    final PackageManager pm = getPackageManager();

    // look for Master Control Panel
    final Intent mcpIntent = new Intent(Intent.ACTION_MAIN);
    mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS);
    final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0);

    // configure link to Master Control Panel
    //final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp);
    if (mcpInfo == null) {
        //   mcpItem.setTextColor(Color.GRAY);
        ColorMatrix grayscale = new ColorMatrix();
        grayscale.setSaturation(0.0f);//from w  ww . j  av  a  2 s.  c  o  m
        //   mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale));
    }
    /*mcpItem.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(final View v) {
    Intent action = mcpIntent;
    if (mcpInfo == null)
       action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI));
    action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    try {
       startActivity(action);
    } catch (final ActivityNotFoundException e) {
       Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show();
    }
    mDrawerLayout.closeDrawers();
       }
    });*/

    // look for other plug-ins
    final Intent utilsIntent = new Intent(Intent.ACTION_MAIN);
    utilsIntent.addCategory(UTILS_CATEGORY);

    final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0);
    for (final ResolveInfo info : appList) {
        final View item = inflater.inflate(R.layout.drawer_plugin, container, false);
        final ImageView icon = (ImageView) item.findViewById(android.R.id.icon);
        final TextView label = (TextView) item.findViewById(android.R.id.text1);

        label.setText(info.loadLabel(pm));
        icon.setImageDrawable(info.loadIcon(pm));
        item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                final Intent intent = new Intent();
                intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(intent);
                mDrawerLayout.closeDrawers();
            }
        });
        container.addView(item);
    }
}

From source file:com.android.contacts.activities.DialtactsActivity.java

/** Returns an Intent to launch Call Settings screen */
public static Intent getCallSettingsIntent() {
    final Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClassName(PHONE_PACKAGE, CALL_SETTINGS_CLASS_NAME);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    return intent;
}

From source file:com.easy.facebook.android.facebook.FBLoginManager.java

public void login() {
    Intent intent = new Intent();
    intent.setClassName("com.facebook.katana", "com.facebook.katana.ProxyAuth");

    if (!validateAppSignatureForIntent(activity, intent)) {
        try {//from   w  w  w .j a v a 2  s  .  c om
            startDialogAuth(activity, permissions);
        } catch (EasyFacebookError e) {
            ((LoginListener) activity).loginFail();

        }
    } else {
        if (permissions.length > 0) {
            intent.putExtra("client_id", appID);
            intent.putExtra("scope", TextUtils.join(",", permissions));
            try {
                activity.startActivityForResult(intent, DEFAULT_AUTH_ACTIVITY_CODE);
            } catch (ActivityNotFoundException e) {
                ((LoginListener) activity).loginFail();
            }
        }
    }
}