SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
36.
• The dark side of AsyncTask
• http://bon-app-etit.blogspot.jp/2013/04/
the-dark-side-of-asynctask.html
• AsyncTask is bad and you should feel bad
• http://simonvt.net/2014/04/17/
asynctask-is-bad-and-you-should-feel-
bad/
52.
import com.squareup.otto.Bus;
public final class BusProvider {
private static final Bus BUS = new Bus();
public static Bus getInstance() {
return BUS;
}
private BusProvider() {
}
}
サンプルコード
「eventbusexample」
69.
new
AlertDialog.Builder(getApplicationContext());
E/AndroidRuntime: Caused by:
android.view.WindowManager$BadTokenException:
Unable to add window -- token null is not for an application
75.
Fragment fragment = new BlankFragment();
fragment.setParam(param);
getFragmentManager().beginTransaction()
.replace(android.R.id.content, fragment)
.commit();
——————————————————————————————————————————————————————
Fragment fragment = new BlankFragment(param1, param2);
getFragmentManager().beginTransaction()
.replace(android.R.id.content, fragment)
.commit();
どっちも
間違い!
76.
public class BlankFragment extends Fragment {
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
private String mParam1;
private String mParam2;
public static BlankFragment newInstance(String param1, String param2) {
BlankFragment fragment = new BlankFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
public BlankFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_blank, container, false);
}