GPS、WIFI、BLUETOOTHの3つの画像ビューがあり、GPS、WIFI、BLUETOOTHがオンの場合(プログラムで)各画像ビューの背景画像を変更したい
GPS、BLUETOOTHがオンの場合、画像が変更されるはずです。それ以外の場合はありません
試してみましたが、うまくいきません
最終的な LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
gpsimg.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
//Toast.makeText(this, "GPS is Enabled in your devide", Toast.LENGTH_SHORT).show();
//showGPSDisabledAlertToUser();
Intent myIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(myIntent);
gpsimg.setImageResource(R.drawable.gps);
}else if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
gpsimg.setImageResource(R.drawable.gps);
}
}
});
ブルートゥースコードはこちら
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
if(!mBtAdapter.isEnabled())
{
bluetoothimg.setImageResource(R.drawable.bt_grey);
Log.i(TAG ,"BLUETOOTH DISABLED") ;
}
bluetoothimg.setOnClickListener(new View. OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
int REQUEST_ENABLE_BT = 1;
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT );
bluetoothimg.setImageResource(R.drawable.bt);
}
});