آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

مشکل با CALL PHONE (حل شد)

میلاد  11 سال پیش  11 سال پیش
0 0

سلام

توی یه برنامه نیاز دارم که سیمکارت ایرانسلی رو از یه شماره دیگه شارژ کنم که کدش هست #شماره تلفن بدون صفر*کد شارژ*141*

توی گوشی اکه به صورت دستی بخوایم این کارو انجام بدیم باید شماره رو بگیریم بعد بهش زنگ بزنیم که به خاطر وجود # در انتها کد دستور ارسال میشه

توی برنامه همین کارو کردم ولی # انتها حذف میشه و به جای اجرای دیسور بهش زنگ میزنه چیکار باید کرد که # انتهاش حذف نشه

اینم کدش

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;


public class SharjActivity extends Activity {

    public Button   btnesharj;
    public EditText edtsharj;
    public String   tell;


    @Override
    public void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.sharj);

        edtsharj = (EditText) findViewById(R.id.edtsharj);
        btnesharj = (Button) findViewById(R.id.btnesharj);

        Cursor cursor = G.database.rawQuery("SELECT * FROM gps WHERE id=1", null);
        while (cursor.moveToNext()) {
            tell = cursor.getString(cursor.getColumnIndex("tell"));
        }
        btnesharj.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                String n = edtsharj.getText().toString();
                String x = tell.substring(1);
                String call = "*141*" + n + "*" + x + "#";
                Log.i("Log", "" + call);
                Intent inten = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + call));
                startActivity(inten);
            }
        });

    }
}

اینم پرمیشن

  <uses-permission android:name="android.permission.CALL_PHONE" />

ممنون میشم اگه راهنمایی کنید .

مرسی

 برای این سوال 1 پاسخ وجود دارد.
پاسخ به سوال 
میلاد  11 سال پیش
+1 0

خوب از A.L.U تشکر میکنم که تو حل این مشکل  کمکم کرد .

گوشی # رو به صورت کد میشناسه یا باید جاش بزنیم 23% یا باید Uri.Encode بگیریم که درست بشه

     @Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.sharj);

edtsharj = (EditText) findViewById(R.id.edtsharj);
btnesharj = (Button) findViewById(R.id.btnesharj);

Cursor cursor = G.database.rawQuery("SELECT * FROM gps WHERE id=1", null);
while (cursor.moveToNext()) {
tell = cursor.getString(cursor.getColumnIndex("tell"));
}
btnesharj.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
String n = edtsharj.getText().toString();
String x = tell.substring(1);
String call = "*141*" + n + "*" + x + "%23";// <======
Log.i("Log", "" + call);
Intent inten = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + call));
startActivity(inten);
}
});

}


یا

     @Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.sharj);

edtsharj = (EditText) findViewById(R.id.edtsharj);
btnesharj = (Button) findViewById(R.id.btnesharj);

Cursor cursor = G.database.rawQuery("SELECT * FROM gps WHERE id=1", null);
while (cursor.moveToNext()) {
tell = cursor.getString(cursor.getColumnIndex("tell"));
}
btnesharj.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
String n = edtsharj.getText().toString();
String x = tell.substring(1);
String call = Uri.encode("*141*" + n + "*" + x + "#");// <========
Log.i("Log", "" + call);
Intent inten = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + call));
startActivity(inten);
}
});

}

 


پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .