Example usage for android.content Intent setClass

List of usage examples for android.content Intent setClass

Introduction

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

Prototype

public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) 

Source Link

Document

Convenience for calling #setComponent(ComponentName) with the name returned by a Class object.

Usage

From source file:com.vuze.android.remote.AndroidUtils.java

public static boolean executeSearch(String search, Context context, SessionInfo sessionInfo) {
    Intent myIntent = new Intent(Intent.ACTION_SEARCH);
    myIntent.setClass(context, MetaSearch.class);
    RemoteProfile remoteProfile = sessionInfo.getRemoteProfile();
    if (remoteProfile != null && remoteProfile.getRemoteType() == RemoteProfile.TYPE_LOOKUP) {
        Bundle bundle = new Bundle();
        bundle.putString("com.vuze.android.remote.searchsource", sessionInfo.getRpcRoot());
        if (remoteProfile.getRemoteType() == RemoteProfile.TYPE_LOOKUP) {
            bundle.putString("com.vuze.android.remote.ac", remoteProfile.getAC());
        }//from   w w w .j  a va2  s  . c o  m
        bundle.putString(SessionInfoManager.BUNDLE_KEY, remoteProfile.getID());

        myIntent.putExtra(SearchManager.APP_DATA, bundle);
    }

    myIntent.putExtra(SearchManager.QUERY, search);

    context.startActivity(myIntent);
    return true;
}

From source file:com.battlelancer.seriesguide.ui.EpisodesFragment.java

/**
 * Display the episode at the given position in a detail pane or if not available in a new
 * activity./*  w ww  .  j a  v a  2s  . c om*/
 */
private void showDetails(View view, int position) {
    if (mDualPane) {
        EpisodesActivity activity = (EpisodesActivity) getActivity();
        activity.setCurrentPage(position);
        setItemChecked(position);
    } else {
        int episodeId = (int) getListView().getItemIdAtPosition(position);

        Intent intent = new Intent();
        intent.setClass(getActivity(), EpisodesActivity.class);
        intent.putExtra(EpisodesActivity.InitBundle.EPISODE_TVDBID, episodeId);

        ActivityCompat.startActivity(getActivity(), intent, ActivityOptionsCompat
                .makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight()).toBundle());
    }
}

From source file:org.kepennar.android.client.social.facebook.FacebookActivity.java

private void showFacebookOptions() {
    String[] options = { "Disconnect", "Profile", "Home Feed", "Wall Post" };
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
            options);//from ww  w . j a  va  2s .c om
    ListView listView = (ListView) this.findViewById(R.id.facebook_activity_options_list);
    listView.setAdapter(arrayAdapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parentView, View childView, int position, long id) {
            Intent intent;
            switch (position) {
            case 0:
                disconnect();
                showConnectOption();
                break;
            case 1:
                intent = new Intent();
                intent.setClass(parentView.getContext(), FacebookProfileActivity.class);
                startActivity(intent);
                break;
            case 2:
                intent = new Intent();
                intent.setClass(parentView.getContext(), FacebookHomeFeedActivity.class);
                startActivity(intent);
                break;
            case 3:
                intent = new Intent();
                intent.setClass(parentView.getContext(), FacebookWallPostActivity.class);
                startActivity(intent);
                break;
            default:
                break;
            }
        }
    });
}

From source file:com.cssweb.android.common.FairyUI.java

public static Intent genIntent(int paramInt1, String paramString1, String paramString2, String paramString3,
        Context paramContext) {/*from  ww  w .  ja  v a 2s  . c o m*/
    Intent localIntent = new Intent();
    // localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    localIntent.putExtra("exchange", paramString1);
    localIntent.putExtra("stockcode", paramString2);
    localIntent.putExtra("stockname", paramString3);
    switch (paramInt1) {
    case Global.QUOTE_KLINE:
        localIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (CssSystem.getSDKVersionNumber() == 4)
            localIntent.setClass(paramContext, KLine2Activity.class);
        else
            localIntent.setClass(paramContext, KLineActivity.class);
        break;
    case Global.QUOTE_F10:
        if ("hk".equals(paramString1)) {
            StringBuffer sb = new StringBuffer();
            sb.append(Config.roadf10);
            sb.append("hkf10/mobile/index.jsp?stockcode=");
            sb.append(paramString1);
            sb.append(paramString2);
            localIntent.putExtra("url", sb.toString());
            localIntent.setClass(paramContext, WebViewDisplay.class);
        } else if ("cf".equals(paramString1) || "dc".equals(paramString1) || "sf".equals(paramString1)
                || "cz".equals(paramString1)) {
            StringBuffer sb = new StringBuffer();
            sb.append(Config.roadf10);
            sb.append("hkf10/front/tbobject3511/indexM.jsp?stockcode=");
            sb.append(paramString1);
            sb.append(paramString2);
            localIntent.putExtra("url", sb.toString());
            localIntent.setClass(paramContext, WebViewDisplay.class);
        } else {
            StringBuffer sb = new StringBuffer();
            sb.append(Config.roadZixun);
            sb.append("iphone/f10/index_forword.jsp?code=");
            sb.append(paramString1);
            sb.append(paramString2);
            localIntent.putExtra("url", sb.toString());
            localIntent.setClass(paramContext, WebViewDisplay.class);
            //localIntent.setClass(paramContext, GetF10List.class);
        }
        break;
    case Global.QUOTE_FENSHI:
        localIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        localIntent.setClass(paramContext, TrendActivity.class);
        break;
    case Global.QUOTE_BAOJIA:
        localIntent.setClass(paramContext, QuotePrice.class);
        break;
    case Global.QUOTE_MINGXI:
        localIntent.setClass(paramContext, QuoteDetail.class);
        break;
    case Global.QUOTE_FLINE:
        localIntent.setClass(paramContext, FLineActivity.class);
        break;
    case Global.QUOTE_USERSTK:
        localIntent.putExtra("requestType", 1);
        localIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        localIntent.setClass(paramContext, PersonalStock.class);
        break;
    case Global.QUOTE_WARN:
        localIntent.putExtra("requestType", 1);
        localIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        localIntent.setClass(paramContext, QuoteSet.class);
        break;
    default:
        localIntent.setClass(paramContext, TrendActivity.class);
        break;

    }
    return localIntent;
}

From source file:org.kepennar.android.client.social.twitter.TwitterActivity.java

private void showTwitterOptions() {
    String[] options = { "Disconnect", "View Profile", "Timeline", "Tweet", "Direct Message" };
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
            options);/*from ww  w  .ja  va2s.  c  o  m*/
    ListView listView = (ListView) this.findViewById(R.id.twitter_activity_options_list);
    listView.setAdapter(arrayAdapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parentView, View childView, int position, long id) {
            Intent intent;
            switch (position) {
            case 0:
                disconnect();
                showConnectOption();
                break;
            case 1:
                intent = new Intent();
                intent.setClass(parentView.getContext(), TwitterProfileActivity.class);
                startActivity(intent);
                break;
            case 2:
                intent = new Intent();
                intent.setClass(parentView.getContext(), TwitterTimelineActivity.class);
                startActivity(intent);
                break;
            case 3:
                intent = new Intent();
                intent.setClass(parentView.getContext(), TwitterTweetActivity.class);
                startActivity(intent);
                break;
            case 4:
                intent = new Intent();
                intent.setClass(parentView.getContext(), TwitterDirectMessageActivity.class);
                startActivity(intent);
                break;
            default:
                break;
            }
        }
    });
}

From source file:reportsas.com.formulapp.Formulario.java

public static void reiniciarActivity(Activity actividad, String parametro) {
    Intent intent = new Intent();

    intent.setClass(actividad, actividad.getClass());
    intent.putExtra("formulario", parametro);
    //llamamos a la actividad
    actividad.startActivity(intent);/*from  w ww.j a  v a2s .c o  m*/
    //finalizamos la actividad actual
    actividad.finish();
}

From source file:com.battlelancer.seriesguide.ui.ActivityFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    int episodeId = (int) id;

    Intent intent = new Intent();
    intent.setClass(getActivity(), EpisodesActivity.class);
    intent.putExtra(EpisodesActivity.InitBundle.EPISODE_TVDBID, episodeId);

    ActivityCompat.startActivity(getActivity(), intent, ActivityOptionsCompat
            .makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight()).toBundle());
}

From source file:com.ape.filemanager.FileExplorerTabActivity.java

/**
 * This is a helper class that implements the management of tabs and all
 * details of connecting a ViewPager with associated TabHost.  It relies on a
 * trick.  Normally a tab host has a simple API for supplying a View or
 * Intent that each tab will show.  This is not sufficient for switching
 * between pages.  So instead we make the content part of the tab host
 * 0dp high (it is not shown) and the TabsAdapter supplies its own dummy
 * view to show as the tab content.  It listens to changes in tabs, and takes
 * care of switch to the correct paged in the ViewPager whenever the selected
 * tab changes.//ww w. j  a v  a 2s.  c  o m
 */
public void startSearchActivity(String path) {
    Intent intent = new Intent();
    intent.setClass(this, FileManagerSearchActivity.class);
    intent.putExtra(FileManagerSearchActivity.CURRENT_PATH, path);
    intent.putExtra(FileManagerSearchActivity.IS_FROM_FILEMANAGER, true);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}

From source file:com.lihu.myscreenengine.Services.Impl.ScreenService.java

public boolean showBottom(Class<? extends Fragment> cls, String id, Intent mIntent, Bundle bundle) {
    final Main mainActivity = (Main) Engine.getInstance().getMainActivity();
    String screen_id = (id == null) ? cls.getCanonicalName() : id;

    Log.v(TAG, screen_id);//from   ww w . j a  va  2s.  c o m

    Intent intent = new Intent(mainActivity, cls);
    if (mIntent != null) {
        intent = mIntent;
        intent.setClass(mainActivity, cls);
    }
    if (bundle != null) {
        intent.putExtras(bundle);
    }
    intent.putExtra("bottom_id", screen_id);
    //      final Window window = mainActivity.getLocalActivityManager().startActivity(screen_id, intent);
    //      if (window != null) {
    //         View view = mainActivity.getLocalActivityManager().startActivity(screen_id, intent).getDecorView();
    //         InputMethodManager imm = (InputMethodManager)mainActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
    //         boolean isOpen=imm.isActive(view);
    //         if(isOpen)
    //            imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
    //         bottom.removeAllViews();
    //         bottom.addView(view, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    //         return true;
    //      }
    return false;
}

From source file:com.lihu.myscreenengine.Services.Impl.ScreenService.java

public boolean showTop(Class<? extends Fragment> cls, String id, Intent mIntent, Bundle bundle) {
    final Main mainActivity = (Main) Engine.getInstance().getMainActivity();
    String screen_id = (id == null) ? cls.getCanonicalName() : id;

    Log.v(TAG, screen_id);/*from www .ja v a  2s  .  c  o  m*/

    Intent intent = new Intent(mainActivity, cls);
    if (mIntent != null) {
        intent = mIntent;
        intent.setClass(mainActivity, cls);
    }
    if (bundle != null) {
        intent.putExtras(bundle);
    }
    intent.putExtra("top_id", screen_id);
    //      final Window window = mainActivity.getLocalActivityManager().startActivity(screen_id, intent);
    //      if (window != null) {
    //         View view = mainActivity.getLocalActivityManager().startActivity(screen_id, intent).getDecorView();
    //         InputMethodManager imm = (InputMethodManager)mainActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
    //         boolean isOpen=imm.isActive(view);
    //         if(isOpen)
    //            imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
    //         top.removeAllViews();
    //         top.addView(view, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    //         return true;
    //      }
    return false;
}