1 | public class MyApplication extends Application { |
Changes in AndroidManifest.xml
1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
Access context wherever you needed, for example:1
2
3
4
5
6
7
8
9
10
11public static void sendHttpRequest(final String address,
final HttpCallbackListener listener) {
…… //do something
if (!isNetworkAvailable()) {
Toast.makeText(MyApplication.getContext()
, "network is unavailable"
,Toast.LENGTH_SHORT).show();
return;
}
…… //do something
}