Android中怎么實(shí)現(xiàn)短信編輯器功能

Android中怎么實(shí)現(xiàn)短信編輯器功能,相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。

10年積累的成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先制作網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有銅陵免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

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="添加當(dāng)前時(shí)間" />
    <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);
    //注冊(cè)控件
    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);
    //獲取當(dāng)前時(shí)間
    getTime.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        textSMS = getMessage.getText().toString();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH時(shí)mm分ss秒");
        Date curDate = new Date(System.currentTimeMillis());//獲取當(dāng)前時(shí)間
        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, "電話號(hào)碼未填寫", Toast.LENGTH_SHORT).show();
          return;
        }
        if (TextUtils.isEmpty(getMessage.getText().toString())) {
          Toast.makeText(MainActivity.this, "短信內(nèi)容未填寫", Toast.LENGTH_SHORT).show();
          return;
        }
        //獲取電話號(hào)碼和短信內(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();
      }
    });
  }
}

看完上述內(nèi)容,你們掌握Android中怎么實(shí)現(xiàn)短信編輯器功能的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

文章題目:Android中怎么實(shí)現(xiàn)短信編輯器功能
文章轉(zhuǎn)載:http://m.kartarina.com/article36/jedjsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版網(wǎng)頁(yè)設(shè)計(jì)公司網(wǎng)站維護(hù)響應(yīng)式網(wǎng)站網(wǎng)站營(yíng)銷軟件開發(fā)

廣告

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

搜索引擎優(yōu)化
主站蜘蛛池模板: 无码137片内射在线影院| 少妇无码AV无码一区| 在线看片无码永久免费视频| 精品欧洲av无码一区二区| 精品久久久久久无码中文野结衣 | 亚洲AV无码专区在线亚| 成人h动漫精品一区二区无码| 亚洲AV无码一区东京热久久| 国产精品爽爽V在线观看无码| 国产成人无码综合亚洲日韩| mm1313亚洲精品无码又大又粗| 日韩精品久久无码中文字幕 | 国产AV无码专区亚洲AV手机麻豆 | 亚洲日产无码中文字幕| 日韩加勒比一本无码精品| 久久久久成人精品无码中文字幕| 亚洲成av人片不卡无码久久| 亚洲av永久无码精品秋霞电影秋 | 亚洲AV无码男人的天堂| 亚洲精品无码不卡在线播放HE| 色综合色国产热无码一 | 亚洲精品一级无码中文字幕| 精品无码久久久久国产动漫3d| 在线观看免费无码专区| 特级无码毛片免费视频| 无码少妇丰满熟妇一区二区| 精品深夜AV无码一区二区| 亚洲av无码国产精品色午夜字幕| 久久久久久av无码免费看大片| 一本大道无码日韩精品影视_| 尤物永久免费AV无码网站| 亚洲爆乳无码精品AAA片蜜桃| 亚洲精品无码久久| 亚洲看片无码在线视频| 2024你懂的网站无码内射| 久久久久久人妻无码| 亚洲午夜无码久久久久小说| 亚洲国产成人精品无码区二本| 无码福利一区二区三区| 亚洲AV无码成人精品区狼人影院| 亚洲中文字幕久久精品无码A|