I have to develop one android application.
Here i have to develop one twitter integration android application.
i have using below code:
public void onClickTwitt() {
if (isNetworkAvailable()) {
Twitt twitt = new Twitt(getActivity(), consumer_key, secret_key);
twitt.shareToTwitter(_Title);
} else {
showToast("No Network Connection Available !!!");
}
}
public boolean isNetworkAvailable() {
ConnectivityManager connectivity =(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
} else {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
return false;
}
Here am getting below error :
The method getSystemService(String) is undefined for the type
SubCate
Please help me...How can i resolve these error ????
public void onClickTwitt() {
if (isNetworkAvailable(this)) {
Twitt twitt = new Twitt(getActivity(), consumer_key, secret_key);
twitt.shareToTwitter(_Title);
} else {
showToast("No Network Connection Available !!!");
}
}
public boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivity =(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
} else {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
for (NetworkInfo networkInfo : info) {
if (networkInfo.getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With