6 |
you need android.permission.CHANGE_NETWORK_STATE permission too | ||
feedback |
2 | You also need to add
to the manifest.xml | |||
feedback |
0 | In your androidmanifest.xml:
|
you need android.permission.CHANGE_NETWORK_STATE permission too | |||
feedback |
You also need to add
to the manifest.xml | ||||
feedback |
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Enable bluetooth:
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
<uses-permission android:name="android.permission.BLUETOOTH" />
You need the following permissions in your manifest file:
Then you can use the following in your activity class:
Use the following to check if it's enabled or not
You'll find a nice tutorial on the subject on this site. wifi toggle power toggle setting |
mp = MediaPlayer.create(Test.this, R.raw.mysound);
mp.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.release();
}
});
mp.start();
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
btnSendSMS.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
sendSMS("5556", "Hi You got a message!");
/*here i can send message to emulator 5556. In Real device
you can change number */
}
});
}
//---sends an SMS message to another device---
private void sendSMS(String phoneNumber, String message)
{
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);
}
}
<uses-permission android:name="android.permission.SEND_SMS"/>
edited Jul 29 '12 at 3:59 |
permission android.permission.WRITE_SYNC_SETTINGS
permission android.permission.READ_SYNC_SETTINGS
in your Manifest.xml