Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[3.144.96.159] |
|
Сообщ.
#1
,
|
|
|
Здравствуйте!пишу программу для отправки и приёма сообщения!с отправкой сообщения проблем ни каких вот только не знаю как реализовать список для отправленных и принятых смс или хотя бы посоветуйте с чего начать!программа для отправки смс ниже
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightSum="1" android:measureWithLargestChild="true"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" androidaddingLeft="2dip" androidaddingRight="4dip" android:text="Recipient Number" /> <EditText android:id="@+id/messageNumber" android:layout_width="fill_parent" android:layout_height="wrap_content" android:cursorVisible="true" android:editable="true" android:singleLine="true" /> <Button android:id="@+id/sayhello" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Отправить" android:onClick="sayHello" /> <FrameLayout android:layout_width="307dp" android:layout_height="102dp" android:background="#ffdeceff"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/edteditText" android:layout_gravity="left|top" /> </FrameLayout> </LinearLayout> package com.example.admin.sms; import android.app.Activity; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.telephony.SmsManager; import android.view.View; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity { /** Called when the activity is first created. */ private EditText messageNumber; private EditText edteditText; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); messageNumber=(EditText)findViewById(R.id.messageNumber); edteditText=(EditText)findViewById(R.id.edteditText); } public void sayHello(View v) { String _messageNumber=messageNumber.getText().toString(); //edteditText.getText().toString(); String messageText = edteditText.getText().toString(); //"Hi , Just SMSed to say hello"; String sent = "SMS_SENT"; PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(sent), 0); registerReceiver(new BroadcastReceiver(){ @Override public void onReceive(Context arg0, Intent arg1) { if(getResultCode() == Activity.RESULT_OK) { Toast.makeText(getBaseContext(), "SMS sent", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getBaseContext(), "SMS could not sent", Toast.LENGTH_SHORT).show(); } } }, new IntentFilter(sent)); SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(_messageNumber, null, messageText, null, null); } } |
Сообщ.
#2
,
Сообщение отклонено: Flex Ferrum -
|
Сообщ.
#3
,
|
|
|
Цитата klepa90 @ Здравствуйте!пишу программу для отправки и приёма сообщения!с отправкой сообщения проблем ни каких вот только не знаю как реализовать список для отправленных и принятых смс или хотя бы посоветуйте с чего начать!программа для отправки смс ниже <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightSum="1" android:measureWithLargestChild="true"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" androidaddingLeft="2dip" androidaddingRight="4dip" android:text="Recipient Number" /> <EditText android:id="@+id/messageNumber" android:layout_width="fill_parent" android:layout_height="wrap_content" android:cursorVisible="true" android:editable="true" android:singleLine="true" /> <Button android:id="@+id/sayhello" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Отправить" android:onClick="sayHello" /> <FrameLayout android:layout_width="307dp" android:layout_height="102dp" android:background="#ffdeceff"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/edteditText" android:layout_gravity="left|top" /> </FrameLayout> </LinearLayout> package com.example.admin.sms; import android.app.Activity; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.telephony.SmsManager; import android.view.View; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity { /** Called when the activity is first created. */ private EditText messageNumber; private EditText edteditText; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); messageNumber=(EditText)findViewById(R.id.messageNumber); edteditText=(EditText)findViewById(R.id.edteditText); } public void sayHello(View v) { String _messageNumber=messageNumber.getText().toString(); //edteditText.getText().toString(); String messageText = edteditText.getText().toString(); //"Hi , Just SMSed to say hello"; String sent = "SMS_SENT"; PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(sent), 0); registerReceiver(new BroadcastReceiver(){ @Override public void onReceive(Context arg0, Intent arg1) { if(getResultCode() == Activity.RESULT_OK) { Toast.makeText(getBaseContext(), "SMS sent", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getBaseContext(), "SMS could not sent", Toast.LENGTH_SHORT).show(); } } }, new IntentFilter(sent)); SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(_messageNumber, null, messageText, null, null); } } Пишите коммерческий код а не тот говнокод который вы привели. |