Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".Lastcall">
- <TextView
- android:id="@+id/lc"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Hello World!"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintRight_toRightOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
- </android.support.constraint.ConstraintLayout>
- package pt.ubi.di.pdm.expermissions1;
- import android.app.Activity;
- import android.database.Cursor;
- import android.net.Uri;
- import android.os.Bundle;
- import android.provider.CallLog;
- import android.widget.TextView;
- public class Lastcall extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_lastcall);
- TextView oTV = (TextView)findViewById(R.id.lc);
- String strUriCalls = "content://call_log/calls";
- Uri uriCalls=Uri.parse(strUriCalls);
- Cursor curCalls = getContentResolver().query(uriCalls ,null ,null ,null , null);
- String sInfo = "Last Call:";
- if (curCalls.moveToLast())
- sInfo += curCalls.getString(curCalls.getColumnIndex(CallLog.Calls.NUMBER))+"n" +
- "Duration:"+curCalls.getString(curCalls.getColumnIndex(CallLog.Calls.DURATION));
- oTV.setText(sInfo);
- }
- }
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="pt.ubi.di.pdm.expermissions1">
- <uses-permission
- android:name="android.permission.READ_CALL_LOG"></uses-permission>
- <application
- android:allowBackup="true"
- android:icon="@mipmap/ic_launcher"
- android:label="@string/app_name"
- android:roundIcon="@mipmap/ic_launcher_round"
- android:supportsRtl="true"
- android:theme="@style/AppTheme">
- <activity android:name=".Lastcall">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
- </manifest>
Add Comment
Please, Sign In to add comment