forward to another Activity
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.view.View;
import android.widget.Button;
class Utils {
public static final String APP_TYPE = "APP_TYPE";
public static <T> void forward(final Button button, final Class<T> clazz,
final Activity activity) {
button.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View arg0) {
SharedPreferences e = activity.getSharedPreferences(APP_TYPE,
Context.MODE_PRIVATE);
Editor edit = e.edit();
edit.putString(APP_TYPE, button.getText().toString());
edit.commit();
Intent intent = new Intent();
intent.setClass(activity, clazz);
activity.startActivity(intent);
}
});
}
}
Related examples in the same category