Handling Data SMS MessagesData messages are received in the same way a dịch - Handling Data SMS MessagesData messages are received in the same way a Việt làm thế nào để nói

Handling Data SMS MessagesData mess

Handling Data SMS Messages
Data messages are received in the same way as normal SMS text messages, and are extracted in the same way as shown in the preceding section. To extract the data transmitted within a data SMS, use the getUserData method:
byte[] data = msg.getUserData();
The getUserData method returns a byte array of the data included in the message.
Emergency Responder SMS Example
In this example, you’ll create an SMS application that turns an Android phone into an emergency response beacon.
When finished, the next time you’re in an unfortunate proximity to an alien invasion or find your¬self in a robot-uprising scenario, you can set your phone to automatically respond to your friends’ and family members’ pleas for a status update with a friendly message (or a desperate cry for help).
To make things easier for your would-be saviors, you can use location-based services to tell your rescuers exactly where to find you. The robustness of SMS network infrastructure makes SMS an excellent option for applications like this, for which reliability is critical.
1. Start by creating a new EmergencyResponder project that features an EmergencyResponder Activity:
package com.paad.emergencyresponder;
import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale;
import java.util.concurrent.locks.ReentrantLock;
import android.app.Activity;
import android.app.Pendinglntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ListView;
public class EmergencyResponder extends Activity {
©Override
public void onCreate(Bundle savedlnstanceState) { super.onCreate(savedlnstanceState); setContentView(R.layout.main);
}
2. Add permissions for finding your location, and for sending and receiving incoming SMS messages to the manifest:



0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Xử lý dữ liệu các tin nhắn SMSThông điệp dữ liệu nhận được trong cùng một cách như là tin nhắn văn bản tin nhắn SMS bình thường, và được khai thác trong cùng một cách như trong các phần trước. Để trích xuất dữ liệu truyền trong một dữ liệu SMS, sử dụng phương pháp getUserData:byte [] dữ liệu = msg.getUserData();Phương pháp getUserData trả về một mảng byte dữ liệu được bao gồm trong thư. Khẩn cấp Responder SMS ví dụTrong ví dụ này, bạn sẽ tạo ra một ứng dụng tin nhắn SMS có thể biến một điện thoại Android thành một đèn hiệu ứng cứu khẩn cấp.Khi hoàn thành, trong thời gian tới bạn đang ở một không may người ngoài hành tinh xâm lược hoặc tìm thấy your¬self trong một kịch bản robot nổi dậy, bạn có thể thiết lập điện thoại của bạn đáp ứng tự động của bạn bè và gia đình lời cầu xin cho một tình trạng Cập Nhật với một thông điệp thân thiện (hoặc một tiếng kêu tuyệt vọng để được giúp đỡ).Để cho dễ dàng hơn cho vị cứu tinh của bạn sẽ được, bạn có thể sử dụng dịch vụ dựa trên vị trí cho cứu hộ của bạn chính xác nơi để tìm thấy bạn. Mạnh mẽ của các cơ sở hạ tầng mạng tin nhắn SMS làm cho tin nhắn SMS một lựa chọn tuyệt vời cho các ứng dụng như thế này, mà độ tin cậy là rất quan trọng.1. bắt đầu bằng cách tạo ra một dự án mới EmergencyResponder rằng tính năng một hoạt động EmergencyResponder:gói com.paad.emergencyresponder;java.io.IOException nhập khẩu; java.util.ArrayList nhập khẩu; java.util.List nhập khẩu; java.util.Locale nhập khẩu;java.util.concurrent.locks.ReentrantLock nhập khẩu;android.app.Activity nhập khẩu;android.app.Pendinglntent nhập khẩu;android.content.BroadcastReceiver nhập khẩu;android.content.Context nhập khẩu;android.content.Intent nhập khẩu;android.content.IntentFilter nhập khẩu;android.location.Address nhập khẩu;android.location.Geocoder nhập khẩu;android.location.Location nhập khẩu;android.location.LocationManager nhập khẩu;android.os.Bundle nhập khẩu;android.telephony.SmsManager nhập khẩu;android.telephony.SmsMessage nhập khẩu;android.util.Log nhập khẩu;android.view.View nhập khẩu;android.widget.ArrayAdapter nhập khẩu;android.widget.Button nhập khẩu;android.widget.CheckBox nhập khẩu;android.widget.ListView nhập khẩu;công cộng lớp EmergencyResponder mở rộng hoạt động {}© Ghi đèkhu vực void onCreate(Bundle savedlnstanceState) {super.onCreate(savedlnstanceState); setContentView(R.layout.main);}2. thêm quyền cho việc tìm kiếm vị trí của bạn, và cho việc gửi và nhận các tin nhắn SMS đến biểu hiện:
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Xử lý dữ liệu tin nhắn SMS
thông điệp dữ liệu nhận được trong cùng một cách như tin nhắn văn bản SMS bình thường, và được chiết xuất trong cùng một cách như trong phần trước. Để trích xuất các dữ liệu được truyền trong một tin nhắn SMS dữ liệu, sử dụng các phương pháp getUserData:
byte [] data = msg.getUserData ();
. Các phương pháp getUserData trả về một mảng byte của dữ liệu chứa trong bản tin
khẩn cấp Responder SMS Ví dụ
Trong ví dụ này, bạn sẽ tạo ra một ứng dụng tin nhắn SMS có thể biến điện thoại Android thành một đèn hiệu ứng phó khẩn cấp.
Khi hoàn thành, thời gian tới bạn đang ở trong một khoảng cách đáng tiếc cho một cuộc xâm lược ngoài hành tinh hoặc tìm your¬self trong một kịch bản robot nổi dậy, bạn có thể thiết lập của bạn điện thoại để tự động trả lời của bạn bè và các thành viên gia đình 'cầu xin cập nhật trạng thái với một thông điệp thân thiện (hoặc một tiếng kêu tuyệt vọng để được giúp đỡ).
để làm cho mọi việc dễ dàng hơn cho-sẽ là vị cứu tinh của bạn, bạn có thể sử dụng các dịch vụ dựa trên địa điểm để nói cứu hộ của bạn chính xác nơi để tìm thấy bạn. Sự vững mạnh của cơ sở hạ tầng mạng SMS làm cho tin nhắn SMS là một lựa chọn tuyệt vời cho các ứng dụng như thế này, mà độ tin cậy là rất quan trọng.
1. Bắt đầu bằng cách tạo ra một dự án EmergencyResponder mới có Hoạt động EmergencyResponder:
gói com.paad.emergencyresponder;
java.io.IOException nhập khẩu; nhập khẩu java.util.ArrayList; nhập khẩu java.util.List; nhập khẩu java.util.Locale;
nhập khẩu java.util.concurrent.locks.ReentrantLock;
nhập khẩu android.app.Activity;
nhập khẩu android.app.Pendinglntent;
nhập khẩu android.content.BroadcastReceiver;
android.content.Context nhập khẩu;
nhập khẩu android.content .Intent;
nhập khẩu android.content.IntentFilter;
nhập khẩu android.location.Address;
nhập khẩu android.location.Geocoder;
nhập khẩu android.location.Location;
nhập khẩu android.location.LocationManager;
nhập khẩu android.os.Bundle;
nhập khẩu android.telephony. SmsManager;
nhập khẩu android.telephony.SmsMessage;
nhập khẩu android.util.Log;
nhập khẩu android.view.View;
nhập khẩu android.widget.ArrayAdapter;
nhập khẩu android.widget.Button;
nhập khẩu android.widget.CheckBox;
nhập khẩu android.widget.ListView ;
public class EmergencyResponder mở rộng Hoạt động {
© Override
public void onCreate (Bundle savedlnstanceState) {super.onCreate (savedlnstanceState); setContentView (R.layout.main);
}
2. Thêm quyền cho việc tìm kiếm vị trí của bạn, và cho việc gửi và nhận tin nhắn SMS đến các biểu hiện:



đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2025 I Love Translation. All reserved.

E-mail: