Skip to content

Instantly share code, notes, and snippets.

View orhanobut's full-sized avatar

Orhan Obut orhanobut

View GitHub Profile
// sender
public class LoginActivity extends Activity {
void displayHome() {
startActivity(HomeActivity.newIntent(this, user));
}
}
// receiver
public class HomeActivity extends Activity {
private static final String KEY_USER = "KEY_USER";
public class Constants {
public static final String KEY_USER = "KEY_USER";
}
// sends the data
public class LoginActivity extends Activity {
void displayHome() {
Intent intent = new Intent(this, HomeActivity.class);
intent.putExtra(Constants.KEY_USER, user);
startActivity(intent);
// sends the data
public class LoginActivity extends Activity {
void displayHome() {
Intent intent = new Intent(this, HomeActivity.class);
intent.putExtra(HomeActivity.KEY_USER, user);
startActivity(intent);
}
}
// gets the data
// sends the data
public class LoginActivity extends Activity {
private static final String KEY_USER = "KEY_USER";
void displayHome() {
Intent intent = new Intent(this, HomeActivity.class);
intent.putExtra(KEY_USER, user);
startActivity(intent);
}
}
public class MyFragment extends Fragment {
private void init() {
for (View view : views) {
view.setBackgroundColor(Color.BLACK);
}
}
}
public class ShareAndImageActivity extends Activity {
ImageHelper imageHelper;
ShareHelper shareHelper;
@Override public void onCreate(Bundle bundle){
...
imageHelper.onCreate(bundle);
shareHelper.onCreate(bundle);
}
public class AccountActivity extends Activity {
ImageHelper imageHelper;
@Override public void onCreate(Bundle bundle){
...
imageHelper.onCreate(bundle);
}
@Override public void onDestroy() {
public class ImageHelper {
public void onCreate(Bundle bundle) {
// init
}
public void onDestroy() {
// release allocations
}
public class ShareActivity extends Activity {
@Override public void onCreate(Bundle bundle){
// init
}
@Override public void onDestroy() {
// release memory
}
public class ProductActivity extends ImageActivity {
@Override public void onCreate(Bundle bundle){
// init
}
public void onAvatarClicked() {
showGalery();
}