欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Android中如何實現(xiàn)短信編輯器功能

這篇文章主要講解了“Android中如何實現(xiàn)短信編輯器功能”,文中的講解內(nèi)容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“Android中如何實現(xiàn)短信編輯器功能”吧!

為新縣等地區(qū)用戶提供了全套網(wǎng)頁設計制作服務,及新縣網(wǎng)站建設行業(yè)解決方案。主營業(yè)務為成都網(wǎng)站設計、成都網(wǎng)站制作、外貿(mào)網(wǎng)站建設、新縣網(wǎng)站設計,以傳統(tǒng)方式定制建設網(wǎng)站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.dudon.fakesms">
  <uses-permission android:name="android.permission.READ_SMS" />
  <uses-permission android:name="android.permission.WRITE_SMS" />
  <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
  </application>
</manifest>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_weight="1"
      android:gravity="center"
      android:text="短信發(fā)送者:"
      android:textSize="18sp" />
    <EditText
      android:id="@+id/get_phone"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_weight="7"
      android:inputType="phone" />
  </LinearLayout>
  <ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1">
    <EditText
      android:id="@+id/get_message"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="20dp"
      android:hint="短信內(nèi)容" />
  </ScrollView>
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <Button
      android:id="@+id/get_time"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_weight="1"
      android:text="添加當前時間" />
    <Button
      android:id="@+id/send_message"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_weight="4"
      android:text="發(fā)送短信" />
  </LinearLayout>
</LinearLayout>

MainActivity.java

public class MainActivity extends AppCompatActivity {
  private int phoneNum;
  private String textSMS;
  private String currentTime;
  private Button sendMessage;
  private Button getTime;
  private EditText getPhone;
  private EditText getMessage;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //注冊控件
    sendMessage = (Button) findViewById(R.id.send_message);
    getTime = (Button) findViewById(R.id.get_time);
    getPhone = (EditText) findViewById(R.id.get_phone);
    getMessage = (EditText) findViewById(R.id.get_message);
    //獲取當前時間
    getTime.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        textSMS = getMessage.getText().toString();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH時mm分ss秒");
        Date curDate = new Date(System.currentTimeMillis());//獲取當前時間
        currentTime = formatter.format(curDate);
        textSMS = textSMS + currentTime;
        getMessage.setText(textSMS);
      }
    });
    //發(fā)送短信
    sendMessage.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        if (TextUtils.isEmpty(getPhone.getText().toString())) {
          Toast.makeText(MainActivity.this, "電話號碼未填寫", Toast.LENGTH_SHORT).show();
          return;
        }
        if (TextUtils.isEmpty(getMessage.getText().toString())) {
          Toast.makeText(MainActivity.this, "短信內(nèi)容未填寫", Toast.LENGTH_SHORT).show();
          return;
        }
        //獲取電話號碼和短信內(nèi)容
        phoneNum = Integer.parseInt(getPhone.getText().toString());
        textSMS = getMessage.getText().toString();
        //開啟多線程
        Thread thread = new Thread() {
          @Override
          public void run() {
            ContentResolver resolver = getContentResolver();
            ContentValues values = new ContentValues();
            values.put("address", phoneNum);
            values.put("type", 1);
            values.put("date", System.currentTimeMillis());
            values.put("body", textSMS);
            resolver.insert(Uri.parse("content://sms"), values);
          }
        };
        thread.start();
        Toast.makeText(MainActivity.this, "短信成功生成", Toast.LENGTH_SHORT).show();
      }
    });
  }
}

感謝各位的閱讀,以上就是“Android中如何實現(xiàn)短信編輯器功能”的內(nèi)容了,經(jīng)過本文的學習后,相信大家對Android中如何實現(xiàn)短信編輯器功能這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

標題名稱:Android中如何實現(xiàn)短信編輯器功能
本文URL:http://aaarwkj.com/article4/peeioe.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、用戶體驗、企業(yè)建站、網(wǎng)站策劃、小程序開發(fā)搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站
国产丝袜在线精品丝袜不卡| 水蜜桃成人在线视频免费观看| 97视频在线观看观看| 99久久精品免费国产一区| 十八禁真人无摭挡观看| 你懂的免费视频中文字幕| 伊人不卡中文字幕在线一区| 国产三级黄色片免费看| 国产av一区二区三区| 不卡在线视频中文字幕| 大秀视频一区二区三区| 国产一级一片内射在线| 性色视频一区二区三区| 亚洲亚洲精品av在线动| 亚洲激情午夜福利视频| 中日韩一二三四区在线看| 国产精品国产成人生活片| 欧美亚洲中文字幕高清| 欧美激情欧美狂野欧美精品| 国产中文字幕乱码中文| 99热国产这里只有精品| 婷婷av一区二区三区| 国产亚洲精品一区久久| 精品一区精品二区国产日韩| 欧美精品一区二区精品久久| 亚洲精品成人午夜久久| 熟女另类视频在线观看| 国产三级国产精品国产| 日韩精品电影一区在线观看| 少妇视频资源一区二区三区| 人妻少妇一区二区三区四区| 日韩一区中文字幕久久| 人人爽久久爱夜夜躁一区| 亚洲av成人在线一区二区| 欧美性生活真实的视频| 91精品国内手机在线高清| 成人性生活毛片免费视频| 黄色午夜福利在线观看| 中文字幕日韩欧美资源站| 视频一区中文字幕在线| 亚洲国产日韩欧美一级|