package com.wissen.sms.receiver;
public class SMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO
}
}
package com.wissen.sms.receiver;
public class SMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO
}
}
<receiver android:name=".receiver.SMSReceiver" android:enabled="true"> <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver> <receiver android:name=".receiver.SMSReceiver" android:enabled="true"> <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission> <uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object messages[] = (Object[]) bundle.get("pdus");
SmsMessage smsMessage[] = new SmsMessage[messages.length];
for (int n = 0; n < messages.length; n++) {
smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
}
// show first message
Toast toast = Toast.makeText(context, "Received SMS: " + smsMessage[0].getMessageBody(), Toast.LENGTH_LONG);
toast.show();
}
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object messages[] = (Object[]) bundle.get("pdus");
SmsMessage smsMessage[] = new SmsMessage[messages.length];
for (int n = 0; n < messages.length; n++) {
smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
}
// show first message
Toast toast = Toast.makeText(context, "Received SMS: " + smsMessage[0].getMessageBody(), Toast.LENGTH_LONG);
toast.show();
}
public static final String MUSIC_ACTION="com.mythlink.MUSIC";
Intent intent=new Intent();
intent.setAction(MUSIC_ACTION);
intent.putExtra("music_path", songPath);
this.sendBroadcast(intent);
public static final String MUSIC_ACTION="com.mythlink.MUSIC";
Intent intent=new Intent();
intent.setAction(MUSIC_ACTION);
intent.putExtra("music_path", songPath);
this.sendBroadcast(intent);
public class MusicReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle=intent.getExtras();
String music_path=bundle.getString("music_path");
Toast toast=Toast.makeText(context, "Playing music:"+music_path, Toast.LENGTH_LONG);
toast.show();
}
}
public class MusicReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle=intent.getExtras();
String music_path=bundle.getString("music_path");
Toast toast=Toast.makeText(context, "Playing music:"+music_path, Toast.LENGTH_LONG);
toast.show();
}
}
public class ContactsList extends ListActivity {
private ListAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Cursor c=this.getContentResolver().query(Contacts.People.CONTENT_URI, null, null, null, null);
this.startManagingCursor(c);
String[] columns=new String[]{Contacts.People.NAME};
int[] names=new int[]{R.id.song};////////////////
mAdapter = new SimpleCursorAdapter(this, R.layout.song_item, c, columns, names);
this.setListAdapter(mAdapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent i=new Intent(Intent.ACTION_CALL);
Cursor c = (Cursor) mAdapter.getItem(position);
long phoneID = c.getLong(c.getColumnIndex(Contacts.People.PRIMARY_PHONE_ID));
i.setData(ContentUris.withAppendedId(Contacts.Phones.CONTENT_URI, phoneID));
this.startActivity(i);
}
}
public class ContactsList extends ListActivity {
private ListAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Cursor c=this.getContentResolver().query(Contacts.People.CONTENT_URI, null, null, null, null);
this.startManagingCursor(c);
String[] columns=new String[]{Contacts.People.NAME};
int[] names=new int[]{R.id.song};////////////////
mAdapter = new SimpleCursorAdapter(this, R.layout.song_item, c, columns, names);
this.setListAdapter(mAdapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent i=new Intent(Intent.ACTION_CALL);
Cursor c = (Cursor) mAdapter.getItem(position);
long phoneID = c.getLong(c.getColumnIndex(Contacts.People.PRIMARY_PHONE_ID));
i.setData(ContentUris.withAppendedId(Contacts.Phones.CONTENT_URI, phoneID));
this.startActivity(i);
}
}
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<activity android:name=".ContactsList"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有