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:ac.robinson.bettertogether.hotspot.HotspotManagerService.java

@SuppressFBWarnings("ANDROID_BROADCAST")
private void sendBroadcastMessageToAllLocalClients(BroadcastMessage msg) {
    for (int i = mClients.size() - 1; i >= 0; i--) {
        try {//  w w w .j a  v a2s  .  c  o m
            // local directly connected activities (i.e., ours)
            Messenger client = mClients.get(i);
            Message message = Message.obtain(null, MSG_BROADCAST);
            message.replyTo = mMessenger;
            Bundle bundle = new Bundle(1);
            bundle.putSerializable(PluginIntent.KEY_BROADCAST_MESSAGE, msg);
            message.setData(bundle);
            client.send(message);

            // local unconnected activities (i.e., plugins)
            Log.d(TAG,
                    "Sending broadcast message to all local clients with package "
                            + mConnectionOptions.mPluginPackage + " - type: " + msg.getType() + ", message: "
                            + msg.getMessage());
            Intent broadcastIntent = new Intent(PluginIntent.ACTION_MESSAGE_RECEIVED);
            broadcastIntent.setClassName(mConnectionOptions.mPluginPackage, PluginIntent.MESSAGE_RECEIVER);
            // TODO: source is only necessary for internal plugins - remove later?
            broadcastIntent.putExtra(PluginIntent.EXTRA_SOURCE, HotspotManagerService.this.getPackageName());
            broadcastIntent.putExtra(PluginIntent.KEY_BROADCAST_MESSAGE, msg);
            sendBroadcast(broadcastIntent);
        } catch (RemoteException e) {
            e.printStackTrace();
            mClients.remove(i); // client is dead - ok to remove here as we're reversing through the list
        }
    }
}

From source file:github.daneren2005.dsub.activity.SubsonicActivity.java

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    if (spinnerAdapter == null) {
        createCustomActionBarView();//w ww .jav  a2 s.  c om
    }
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    // Sync the toggle state after onRestoreInstanceState has occurred.
    if (drawerToggle != null) {
        drawerToggle.syncState();
    }

    if (Util.shouldStartOnHeadphones(this)) {
        Intent serviceIntent = new Intent();
        serviceIntent.setClassName(this.getPackageName(), HeadphoneListenerService.class.getName());
        this.startService(serviceIntent);
    }
}

From source file:org.zeroxlab.benchmark.Benchmark.java

public void onClick(View v) {
    if (v == mRun) {
        int numberOfCaseChecked = 0;
        for (int i = 0; i < mCheckList.length; i++) {
            if (mCheckList[i].isChecked()) {
                mCases.get(i).reset();/*from w  w w .j  a v a2 s  .c  om*/
                numberOfCaseChecked++;
            } else {
                mCases.get(i).clear();
            }
        }
        if (numberOfCaseChecked > 0)
            runCase(mCases);
    } else if (v == mShow) {
        String result = getResult();
        Log.i(TAG, "\n\n" + result + "\n\n");
        writeResult(mOutputFile, result);
        Intent intent = new Intent();
        intent.putExtra(Report.REPORT, result);
        intent.putExtra(Report.XML, mXMLResult);
        if (mAutoUpload) {
            intent.putExtra(Report.AUTOUPLOAD, true);
            mAutoUpload = false;
        }
        intent.setClassName(Report.packageName(), Report.fullClassName());
        startActivity(intent);
    } else if (v == d2CheckBox || v == d2HWCheckBox || v == d2SW1CheckBox || v == d2SW2CheckBox
            || v == d3CheckBox || v == mathCheckBox || v == vmCheckBox || v == nativeCheckBox
            || v == miscCheckBox) {
        int length = mCases.size();
        String tag = ((CheckBox) v).getText().toString();
        for (int i = 0; i < length; i++) {
            if (!mCategory.get(tag).contains(mCases.get(i)))
                continue;
            mCheckList[i].setChecked(((CheckBox) v).isChecked());
        }
    } else if (v == filterBitmapCheckBox) {
        sFilterBitmap = filterBitmapCheckBox.isChecked();
    } else if (v == useGradientCheckBox) {
        sUseGradient = useGradientCheckBox.isChecked();
    } else if (v == useTextureCheckBox) {
        sUseTexture = useTextureCheckBox.isChecked();
    }
}

From source file:ac.robinson.bettertogether.hotspot.HotspotManagerService.java

@SuppressFBWarnings("ANDROID_BROADCAST")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onClientMessageError(ClientMessageErrorEvent event) {
    Log.d(TAG, "Client message error (event) " + event.mType);

    // client message error - a client's connection to the remote server failed
    switch (event.mType) {
    case WIFI://from w  w  w . j  a  v a 2  s  .c  om
        Log.d(TAG, "Wifi client failed - restarting");
        retryWifiConnection();

        sendSystemMessageToAllLocalClients(EVENT_LOCAL_CLIENT_ERROR, event.mType.toString());

        // stop local unconnected activities (i.e., plugins)
        Log.d(TAG, "Sending stop command to all local plugins");
        Intent wifiStopIntent = new Intent(PluginIntent.ACTION_STOP_PLUGIN);
        wifiStopIntent.setClassName(mConnectionOptions.mPluginPackage, PluginIntent.MESSAGE_RECEIVER);
        // TODO: source is only necessary for internal plugins - remove later?
        wifiStopIntent.putExtra(PluginIntent.EXTRA_SOURCE, HotspotManagerService.this.getPackageName());
        sendBroadcast(wifiStopIntent);
        break;

    case BLUETOOTH:
        Log.d(TAG, "Bluetooth client failed - restarting");
        retryBluetoothConnection();

        sendSystemMessageToAllLocalClients(EVENT_LOCAL_CLIENT_ERROR, event.mType.toString());

        // stop local unconnected activities (i.e., plugins)
        Log.d(TAG, "Sending stop command to all local plugins");
        Intent bluetoothStopIntent = new Intent(PluginIntent.ACTION_STOP_PLUGIN);
        bluetoothStopIntent.setClassName(mConnectionOptions.mPluginPackage, PluginIntent.MESSAGE_RECEIVER);
        // TODO: source is only necessary for internal plugins - remove later?
        bluetoothStopIntent.putExtra(PluginIntent.EXTRA_SOURCE, HotspotManagerService.this.getPackageName());
        sendBroadcast(bluetoothStopIntent);
        break;

    case UNKNOWN:
    default:
        if (!mHotspotMode) {
            // TODO: this is caused by RemoteConnection - messages has failed, but the connection is still apparently ok
            // TODO: - should we kill the connection after a certain number of these?
            Log.d(TAG, "Client message error with unknown source - ignoring");
        } else {
            // on the server, we get error messages with source set to unknown - this is caused by the fact that all
            // connections extend RemoteConnection, and that class sends client errors rather than differentiating
            // between client and server (a limitation). When this happens, there is no need to do anything here,
            // because we get a ServerMessageErrorEvent from [Wifi|Bluetooth]ServerConnection classes when the failure
            // actually happens, and a further ServerMessageErrorEvent from [Wifi|Bluetooth]Server when the dead client
            // is removed from the list of connected sockets.
        }
        break;
    }
}

From source file:com.flipzu.flipzu.Player.java

private Void logoutPlayer() {
    /* track "Logout" */
    tracker.trackEvent("Player", "Click", "Logout", 0);

    /* stop player service */
    stopService(intent);// www .j a  v  a 2 s  .co m

    SharedPreferences.Editor editor = settings.edit();
    editor.putString("username", null);
    editor.putString("token", null);
    editor.commit();
    Intent loginIntent = new Intent();
    loginIntent.setClassName("com.flipzu.flipzu", "com.flipzu.flipzu.Flipzu");
    startActivity(loginIntent);
    Player.this.finish();
    return null;
}

From source file:com.paywith.ibeacon.service.IBeaconService.java

protected void moveLocationToTop(String location_id) {
    Intent intent = new Intent("android.intent.category.LAUNCHER");
    intent.setClassName("com.paywith.paywith", "com.paywith.paywith.MainActivity");
    intent.putExtra("location_id", location_id);
    //intent.setClassName("com.paywith.paywith", "com.paywith.paywith.BeaconToAppActivity");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);/*from ww w  . j  a v a  2  s .  c  o m*/
}

From source file:com.paywith.ibeacon.service.IBeaconService.java

private void launchApp(String murl) {
    // call this to launch the main paywith app
    Intent intent = new Intent("android.intent.category.LAUNCHER");
    intent.setClassName("com.paywith.paywith", "com.paywith.paywith.MainActivity");
    //intent.setClassName("com.paywith.paywith", "com.paywith.paywith.BeaconToAppActivity");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("OpenUrl", murl);
    startActivity(intent);//from  w  w w.j av a  2  s  .  c  o m
}

From source file:com.freeme.filemanager.view.FileViewFragment.java

@Override
public boolean onRefreshFileList(String path, FileSortHelper sort) {
    if (optionMenu != null) {
        mFileViewInteractionHub.onPrepareOptionsMenu(optionMenu);
    }/*from ww  w . j  a  v  a2 s. c  o  m*/
    //*/ Added by tyd wulinaghuan 2013-12-09 for: fix NullPointerException bug
    if (TextUtils.isEmpty(path)) {
        return false;
    }
    //*/
    final File file = new File(path);
    if (!file.exists() || !file.isDirectory()) {
        return false;
    }
    final int pos = computeScrollPosition(path);
    final ArrayList<FileInfo> fileList = mFileNameList;
    fileList.clear();

    //modify by tyd mingjun 20150526 for refresh slowly
    if (isFirst) {
        isFirst = false;
        handler = new Handler() {
            public void handleMessage(Message msg) {
                if (msg.what == 0 && fileList.isEmpty()) {
                    if (isLayout == 0 && loadDialog != null) {
                        if (mTagPath != null) {
                            if (!mTagPath.equals(file.getAbsolutePath())) {
                                loadDialog.show();
                            }
                        } else {
                            Intent intent = new Intent();
                            intent.setClassName(BuildConfig.APPLICATION_ID, "FileExplorerTabActivity");
                            if (mActivity.getPackageManager().resolveActivity(intent, 0) != null) {
                                loadDialog.show();
                            }
                        }
                    }
                }
            };
        };
        new Thread(new ThreadShow()).start();
        LoadlistDataTask listData = new LoadlistDataTask(file, fileList, sort, pos);
        listData.execute();
    } else {
        File[] listFiles = file.listFiles(mFileCagetoryHelper.getFilter());
        if (listFiles == null)
            return true;
        //modify by tyd liuyong 20140504 for refresh slowly
        for (File child : listFiles) {
            // do not show selected file if in move state

            if (mFileViewInteractionHub.inMoveState()
                    && mFileViewInteractionHub.isFileSelected(child.getPath()))
                continue;
            String absolutePath = child.getAbsolutePath();
            if (Util.isNormalFile(absolutePath) && Util.shouldShowFile(absolutePath)) {
                FileInfo lFileInfo = Util.GetFileInfo(child, mFileCagetoryHelper.getFilter(),
                        Settings.instance().getShowDotAndHiddenFiles());
                if (lFileInfo != null && !lFileInfo.fileName.equals("droi")) {
                    fileList.add(lFileInfo);
                }
            }

        }
        mTagPath = file.getAbsolutePath();
        sortCurrentList(sort);
        showEmptyView(fileList.size() == 0);
        mFileListView.post(new Runnable() {
            @Override
            public void run() {
                mFileListView.setSelection(pos);
            }
        });
    }

    // add by xueweili for listview to check on 20160407
    //mFileListView.requestFocusFromTouch();
    //end
    return true;
}

From source file:org.mozilla.gecko.GeckoAppShell.java

public static void createShortcut(final String aTitle, final String aURI, final Bitmap aIcon,
        final String aType) {
    getHandler().post(new Runnable() {
        public void run() {
            Log.w(LOGTAG, "createShortcut for " + aURI + " [" + aTitle + "] > " + aType);

            // the intent to be launched by the shortcut
            Intent shortcutIntent = new Intent();
            if (aType.equalsIgnoreCase("webapp")) {
                shortcutIntent.setAction(GeckoApp.ACTION_WEBAPP);
                shortcutIntent.setData(Uri.parse(aURI));
            } else {
                shortcutIntent.setAction(GeckoApp.ACTION_BOOKMARK);
                shortcutIntent.setData(Uri.parse(aURI));
            }//from www  .j a  v a2 s. c om
            shortcutIntent.setClassName(GeckoApp.mAppContext, GeckoApp.mAppContext.getPackageName() + ".App");

            Intent intent = new Intent();
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
            if (aTitle != null)
                intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, aTitle);
            else
                intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, aURI);
            intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, getLauncherIcon(aIcon));
            intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
            GeckoApp.mAppContext.sendBroadcast(intent);
        }
    });
}

From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java

private void shareOnTwitter() {
    String shareString = isSessionLive() ? (mHashTag + " ")
            : getString(R.string.share_template, mTitleString, UIUtils.getSessionHashtagsString(mHashTag),
                    " " + mUrl);

    ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder.from(getActivity()).setType("text/plain")
            .setText(shareString);//  w  w w.  j  a  v  a2 s .c  om

    Intent intent = builder.getIntent();

    ActivityInfo twitterPackage = PackageHelper.findTwitterPackage(getActivity());

    intent.setClassName(twitterPackage.packageName, twitterPackage.name);
    startActivity(intent);
}