M
M
MODifikaTOR2017-03-22 08:49:13
Java
MODifikaTOR, 2017-03-22 08:49:13

How to put a condition on a call or SMS request?

I encountered such a bug: the application must make a call to the dialed number, or send an SMS request if the number is coded (for example, *100#, *113#, etc.). How can I implement this? Or where do they write about it?
Call call code:

Activity activity;
    String phoneNumber;
    ArrayList<HashMap<String, String>> Array_of_phones = new ArrayList<HashMap<String, String>>();
    Map element;
phone_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                element = (Map<String, String>)adapter.getItem(position);
                Intent myIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + element.get("phone")));
                myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
                    // TODO: Consider calling
                    //    ActivityCompat#requestPermissions
                    // here to request the missing permissions, and then overriding
                    //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                    //                                          int[] grantResults)
                    // to handle the case where the user grants the permission. See the documentation
                    // for ActivityCompat#requestPermissions for more details.
                    return;
                }
                startActivity(myIntent);
            }
        });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question