Android examples for Intent:Open App
create Intent
/**//from w w w . j a v a 2 s . c o m Copyright (C) 2010 Forrest Guice This file is part of Thunder-Stopwatch. Thunder-Stopwatch is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Thunder-Stopwatch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Thunder-Stopwatch. If not, see <http://www.gnu.org/licenses/>. */ //package com.java2s; import android.content.Context; import android.content.Intent; public class Main { public static Intent createIntent(Context context, Class<?> classObj) { Class<?> activityClass = getActivityClass(context, classObj); return new Intent(context, activityClass); } private static Class<?> getActivityClass(Context context, Class<?> classObj) { StringBuilder b = new StringBuilder(255); b.append(context.getPackageName()); b.append("."); b.append(classObj.getSimpleName()); b.append("Ext"); String extClassName = b.toString(); try { Class<?> extClass = Class.forName(extClassName); return extClass; } catch (ClassNotFoundException e) { //e.printStackTrace(); // DEBUG: uncomment to debug return classObj; } } }