简体   繁体   English

如何设置Android Intent.ACTION_CALL,来自lstBook的Uri编号= new ArrayList <>();

[英]how can set Android Intent.ACTION_CALL, Uri number from lstBook = new ArrayList<>();

I have created android app like gallery which have some images using gridview fragment. 我已经创建了像图库这样的Android应用程序,其中有一些使用gridview片段的图像。

Functionality is working fine also my click button for dail USSD code working. 功能正常,我的单击按钮也可以正常运行USSD代码。

1st of all sorry because I don't know how can I explain my requirement or question. 首先抱歉,因为我不知道如何解释我的要求或问题。

I need help that how can I get USSD code from gridview like Title , Description . 我需要如何从gridview获得USSD代码(例如TitleDescription

Here is my code : 这是我的代码:

lstBook = new ArrayList<>();
lstBook.add(new Book("*111", "Categorie Book", "Description book", R.drawable.person7));

Here is my code of next activity : 这是我的下一个活动代码:

    public class Book_Activity extends AppCompatActivity {

        private TextView tvtitle,tvdescription,tvcategory;
        private ImageView img;
        private Button btn;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_book_);


            tvtitle = (TextView) findViewById(R.id.txttitle);
            tvdescription = (TextView) findViewById(R.id.txtDesc);
            tvcategory = (TextView) findViewById(R.id.txtCat);
            img = (ImageView) findViewById(R.id.bookthumbnail);

            // Recieve data
            Intent intent = getIntent();
            String Title = intent.getExtras().getString("Title");
            String Description = intent.getExtras().getString("Description");
            int image = intent.getExtras().getInt("Thumbnail") ;

            // Setting values

            tvtitle.setText(Title);
            tvdescription.setText(Description);
            img.setImageResource(image);

            btn = (Button) findViewById(R.id.button);

            btn.setOnClickListener(new View.OnClickListener(){

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub


                    String phone = "*1111111111";
                String encodedHash = Uri.encode("#");
                Intent intent = new Intent(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:" + phone+encodedHash));
                    startActivity(intent);

                }
            });
        }
    } 

I want String phone = tvtitle from my gridview 我想从我的gridview String phone = tvtitle

My intent showing as *1111111111# but I want *111# 我的意图显示为*1111111111#但我想要*111#

i have solve my question by myself and am answering here for other user can get help 我自己解决了我的问题,并在这里回答其他用户可以获得帮助

Change String phone String phone = "*1111111111"; 更改String phone String phone =“ * 1111111111”; with String phone = tvtitle.getText().toString(); 使用String phone = tvtitle.getText()。toString();

@Override
            public void onClick(View v) {
                // TODO Auto-generated method stub


                //String phone = "*1111111111";
            String phone = tvtitle.getText().toString();
            String encodedHash = Uri.encode("#");
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:" + phone+encodedHash));
                startActivity(intent);

            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM