Intent setClass - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Intent setClass method.

This code example shows how to use the following methods:finish, startActivity, setClass, makeText
 
    protected void onPostExecute(String message) {
        dialog.hide();
        dialog.cancel();
 
        Toast.makeText(context,message,Toast.LENGTH_LONG).show();
 
		Intent i = new Intent().setClass(context, TabWidget.class);
		context.startActivity(i);
 
        context.finish();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:putExtra, setClass
		User user = (User)adapter.getItem(position);
		if (user == null) {
            return; 
        } 
 
		Intent intent = new Intent();
		intent.putExtra("USER", user);
		intent.setClass(parent.getContext(), ProfileActivity.class);
		context.startActivity(intent);
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:setClass
        } 
        super.tearDown(); 
    } 
 
    public void test_createRequestFactory_returns_default_factory() { 
        Intent startIntent = new Intent();
        startIntent.setClass(getContext(), RetrofitSpiceTestService.class);
        startService(startIntent);
        assertNotNull(getService().createRestAdapterBuilder());
    } 
 
    public void test_addRequest_injects_request_factory() throws InterruptedException { 
        // given 
        spiceManager.start(getContext());
        RetrofitSpiceRequestStub retrofitSpiceRequestStub = new RetrofitSpiceRequestStub(WeatherResult.class);
 
        // when 
        spiceManager.execute(retrofitSpiceRequestStub, new RequestListenerStub<WeatherResult>());
        retrofitSpiceRequestStub.await(REQUEST_COMPLETION_TIMEOUT);
 
7
CodeRank
This code example shows how to use the following methods:setClass
        ActivityOnClick(ComponentName className) {
            mClassName = className;
        } 
 
        public void onClick(View v) {
            Intent intent = new Intent(
                null, Uri.fromParts("component",
                    mClassName.flattenToString(), null));
            intent.setClass(PackageSummary.this, ShowActivity.class);
            startActivity(intent);
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:putExtra, setClass
        result.setClassName(pkg, componentName);
        return result;
    } 
 
    protected Intent browseIntent(String path) {
        Intent result = new Intent();
        result.setClass(this, ListSamples.class);
        result.putExtra("com.jakewharton.android.viewpagerindicator.sample.Path", path);
        return result;
    } 
 
    protected void addItem(List<Map<String, Object>> data, String name, Intent intent) {
        Map<String, Object> temp = new HashMap<String, Object>();
        temp.put("title", name);
        temp.put("intent", intent);
        data.add(temp);
    } 
 
    @Override 
    @SuppressWarnings("unchecked") 
9
CodeRank
This code example shows how to use the following methods:addFlags, setClass, setData
            } 
        } 
    } 
     
    void grantUriPermissionFail(Uri uri, int mode, boolean service) {
        Intent grantIntent = new Intent();
        grantIntent.setData(uri);
        grantIntent.addFlags(mode);
        grantIntent.setClass(getContext(),
                service ? ReceiveUriService.class : ReceiveUriActivity.class);
        Intent intent = new Intent();
        intent.setComponent(GRANT_URI_PERM_COMP);
        intent.putExtra("intent", grantIntent);
        intent.putExtra("service", service);
        GrantResultReceiver receiver = new GrantResultReceiver();
        getContext().sendOrderedBroadcast(intent, null, receiver, null, 0, null, null);
        receiver.assertFailure("Able to grant URI permission to " + uri + " when should not");
    } 
 
    void doTestGrantUriPermissionFail(Uri uri) {
7
CodeRank
This code example shows how to use the following methods:putExtra, setClass
        result.setClassName(pkg, componentName);
        return result;
    } 
 
    protected Intent browseIntent(String path) {
        Intent result = new Intent();
        result.setClass(this, Support13Demos.class);
        result.putExtra("com.example.android.apis.Path", path);
        return result;
    } 
 
    protected void addItem(List<Map<String, Object>> data, String name, Intent intent) {
        Map<String, Object> temp = new HashMap<String, Object>();
        temp.put("title", name);
        temp.put("intent", intent);
        data.add(temp);
    } 
 
    @Override 
    @SuppressWarnings("unchecked") 
7
CodeRank
This code example shows how to use the following methods:addFlags, putExtra, setClass, setClipData
    @SuppressLint("NewApi") 
    public static Intent createChooser(Intent target, CharSequence title) {
        if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
            return Intent.createChooser(target, title);
        } 
        Intent intent = new Intent();
        intent.setClass(Application.getLastInstance(), ChooserActivity.class);
        intent.putExtra(Intent.EXTRA_INTENT, target);
        if (title != null) {
            intent.putExtra(Intent.EXTRA_TITLE, title);
        } 
        int permFlags = target.getFlags()
                & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        if (permFlags != 0 && VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
            ClipData targetClipData = target.getClipData();
            if (targetClipData == null && target.getData() != null) {
                ClipData.Item item = new ClipData.Item(target.getData());
                String[] mimeTypes;
                if (target.getType() != null) {
                    mimeTypes = new String[]{

9
CodeRank
This code example shows how to use the following methods:setClass
            button.setOnClickListener(mStopListener);
        } 
 
        private OnClickListener mForegroundListener = new OnClickListener() {
            public void onClick(View v) { 
                Intent intent = new Intent(ForegroundService.ACTION_FOREGROUND); 
                intent.setClass(Controller.this, ForegroundService.class); 
                startService(intent); 
            } 
        }; 
 
        private OnClickListener mBackgroundListener = new OnClickListener() {
            public void onClick(View v) { 
                Intent intent = new Intent(ForegroundService.ACTION_BACKGROUND); 
                intent.setClass(Controller.this, ForegroundService.class); 
                startService(intent); 
            } 
        }; 
 
        private OnClickListener mStopListener = new OnClickListener() {
7
CodeRank
This code example shows how to use the following methods:putExtra, setClass
        result.setClassName(pkg, componentName);
        return result;
    } 
 
    protected Intent browseIntent(String path) {
        Intent result = new Intent();
        result.setClass(this, SampleList.class);
        result.putExtra("com.example.android.apis.Path", path);
        return result;
    } 
 
    protected void addItem(List<Map<String, Object>> data, String name, Intent intent) {
        Map<String, Object> temp = new HashMap<String, Object>();
        temp.put("title", name);
        temp.put("intent", intent);
        data.add(temp);
    } 
 
    @Override 
    @SuppressWarnings("unchecked") 
8
CodeRank

Related Intent setClass Questions & Answers:

setClass Method Overview
Convenience for calling setComponent(ComponentName) with the name returned by a Class object.
See Code Examples for other Android Intent Methods: