Огромное спасибо за подсказки, но при получении смс в TextView попадают значения из 11 строки String pipeline. А хотелось бы что бы TextView попадали значения из приходящей смс. И у меня нет привычки постить картинки, я только один раз и уже исправился.)))
Java |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Получите дополнительные данные
Bundle extras = getIntent().getExtras();
String address = extras.getString("address");
String message = extras.getString("message");
String pipeline = "dom:-11.1;25;738;-22.2;40;on;";
String split[] = pipeline.split(";");
String one = split[0].split(":")[0];
String two = split[1];
String three = split[2];
String four = split[3];
String five = split[4];
String six = split[5];
TextView addresstv = (TextView) findViewById(R.id.addresstv);
TextView messagetv = (TextView) findViewById(R.id.messagetv);
TextView tv1 = (TextView) findViewById(R.id.one);
TextView tv2 = (TextView) findViewById(R.id.two);
TextView tv3 = (TextView) findViewById(R.id.three);
TextView tv4 = (TextView) findViewById(R.id.four);
TextView tv5 = (TextView) findViewById(R.id.five);
TextView tv6 = (TextView) findViewById(R.id.six);
tv1.setText(one);
tv2.setText(two);
tv3.setText(three);
tv4.setText(four);
tv5.setText(five);
tv6.setText(six);
messagetv.setText(message);
addresstv.setText(address);
}} |
|
Java |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| public class SmsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context ctx, Intent intent) {
Bundle bundle = intent.getExtras();
Object[] pdus = (Object[]) bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < messages.length; i++){
messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
if (messages[i].getDisplayOriginatingAddress().contains("1028")) {
Intent newintent = new Intent(ctx, MainActivity.class);
newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Проход в данных
newintent.putExtra("address", messages[i].getDisplayOriginatingAddress());
newintent.putExtra("message", messages[i].getDisplayMessageBody());
ctx.startActivity(newintent);
} } }
} |
|