View Full Version : درخواست کدهای ارسال پیامک به سازنده برنامه در اندروید
  
ehsanh22
سه شنبه 27 آبان 1393, 01:48 صبح
سلام دوستان
من توی برنامه هایی دیدم در بخش درباره نرم افزارشون این دو دکمه رو داره : ارسال اس ام اس - ارسال ایمیل که وقتی روش میزنی صفحه ای مصل دیالوگ باز میشه میتونی متن رو بزنی و ارسال بزنی . کسی کدش رو داره؟! ممنونم
ho33ein19
سه شنبه 27 آبان 1393, 07:25 صبح
package com.hb.photoshop;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Sms extends Activity {
    Button btn_send, btn_mail, buttonSend;
    EditText txt_number, textTo, textSubject, textMessage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_sms);
        btn_mail = (Button) findViewById(R.id.buttonemail);
        textMessage = (EditText) findViewById(R.id.editTextSMS);
        btn_send = (Button) findViewById(R.id.buttonSend);
        
        btn_send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                
                    String message = textMessage.getText().toString();
                    Intent sendSms=new Intent(Intent.ACTION_VIEW);
                    sendSms.putExtra("sms_body", message);
                    sendSms.putExtra("address", "Your Number");
                    sendSms.setType("vnd.android-dir/mms-sms");
                    startActivity(sendSms);
            }
        });
        
        btn_mail.setOnClickListener(new View.OnClickListener() {
             
            @Override
            public void onClick(View v) {
 
              String to = "your Email".toString();
              String subject = "آموزش فتوشاپ".toString();
              String message = textMessage.getText().toString();
 
              Intent email = new Intent(Intent.ACTION_SEND);
              email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
              email.putExtra(Intent.EXTRA_CC, new String[]{ to});
              email.putExtra(Intent.EXTRA_BCC, new String[]{to});
              email.putExtra(Intent.EXTRA_SUBJECT,subject);
              email.putExtra(Intent.EXTRA_TEXT, message);
              //need this to prompts email client only
              email.setType("message/rfc822");
              
              startActivity(Intent.createChooser(email, "Choose an Email client :"));
              
            }
        });
    }
}
miladamini19
سه شنبه 27 آبان 1393, 09:57 صبح
در چه محیطی ؟
b4a رو هم خواستید من دارم
ehsanh22
چهارشنبه 28 آبان 1393, 02:08 صبح
من برای اکلیپس میخوام 
این کدی که دادید فقط برای کلس هست حالا xml چجوری بسازم
من حرفه ای نیستم تازه واردم
ho33ein19
چهارشنبه 28 آبان 1393, 09:20 صبح
این هم فایل xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#222222"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/textViewSMS"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:text="متن پیام :\n"
        android:textColor="#fff"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    <EditText
        android:id="@+id/editTextSMS"
        android:layout_width="match_parent"
        android:layout_height="188dp"
        android:gravity="top"
        android:hint="لطفا نظرات و پیشنهادات خود را برای ما بفرستید"
        android:inputType="textMultiLine"
        android:lines="5"
        android:textColor="#fff" />
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center" >
        <Button
            android:id="@+id/buttonSend"
            android:layout_width="150dp"
            android:layout_height="40dp"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="4dp"
            android:layout_alignParentTop="true"
           
            android:textColor="#fff"
            android:text="ارسال پیام" />
        <Button
            android:id="@+id/buttonemail"
            android:layout_width="150dp"
            android:layout_height="40dp"
            android:layout_marginRight="4dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            
            android:textColor="#fff"
            android:text="ارسال ایمیل" />
        
    </RelativeLayout>
</LinearLayout>
ehsanh22
جمعه 30 آبان 1393, 04:14 صبح
تشکر ممنونم دوست خوبم جواب داد .
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.