0

I to display phone call history when a user clicks a button. Can this be done with an intent? Which intent should I use?

Jon
  • 7,185
  • 6
  • 45
  • 66
  • Possible duplicate of [Open another application from your own (intent)](https://stackoverflow.com/questions/2780102/open-another-application-from-your-own-intent) – Phil3992 May 22 '17 at 14:29
  • Welcome to Stack Overflow! I made some minor edits. I changed the title of your question to better describe the underlying question. – Jon May 23 '17 at 18:27

1 Answers1

1

You can do this using Intent with action Intent.ACTION_VIEW and type CallLog.Calls.CONTENT_TYPE;

Try this:

yourButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intentCallLog = new Intent();
            intentCallLog.setAction(Intent.ACTION_VIEW);
            intentCallLog.setType(CallLog.Calls.CONTENT_TYPE);
            startActivity(intentCallLog);
        }
    });

Make sure you have added the permission android.permission.READ_CALL_LOG into your AndroidManifest.xml file.

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

READ_CALL_LOG: Allows an application to read the user's call log.

Note: If your app uses the READ_CONTACTS permission and both your minSdkVersion and targetSdkVersion values are set to 15 or lower, the system implicitly grants your app this permission. If you don't need this permission, be sure your targetSdkVersion is 16 or higher.

See documentation.

Hope this will help~

Ferdous Ahamed
  • 19,328
  • 5
  • 45
  • 54