Guest User

Untitled

a guest
Nov 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent"
  7. tools:context=".Lastcall">
  8.  
  9. <TextView
  10. android:id="@+id/lc"
  11. android:layout_width="wrap_content"
  12. android:layout_height="wrap_content"
  13. android:text="Hello World!"
  14. app:layout_constraintBottom_toBottomOf="parent"
  15. app:layout_constraintLeft_toLeftOf="parent"
  16. app:layout_constraintRight_toRightOf="parent"
  17. app:layout_constraintTop_toTopOf="parent" />
  18.  
  19. </android.support.constraint.ConstraintLayout>
  20.  
  21. package pt.ubi.di.pdm.expermissions1;
  22.  
  23. import android.app.Activity;
  24. import android.database.Cursor;
  25. import android.net.Uri;
  26. import android.os.Bundle;
  27. import android.provider.CallLog;
  28. import android.widget.TextView;
  29.  
  30. public class Lastcall extends Activity {
  31.  
  32. @Override
  33. protected void onCreate(Bundle savedInstanceState) {
  34. super.onCreate(savedInstanceState);
  35. setContentView(R.layout.activity_lastcall);
  36. TextView oTV = (TextView)findViewById(R.id.lc);
  37. String strUriCalls = "content://call_log/calls";
  38. Uri uriCalls=Uri.parse(strUriCalls);
  39. Cursor curCalls = getContentResolver().query(uriCalls ,null ,null ,null , null);
  40. String sInfo = "Last Call:";
  41.  
  42.  
  43. if (curCalls.moveToLast())
  44. sInfo += curCalls.getString(curCalls.getColumnIndex(CallLog.Calls.NUMBER))+"n" +
  45. "Duration:"+curCalls.getString(curCalls.getColumnIndex(CallLog.Calls.DURATION));
  46. oTV.setText(sInfo);
  47.  
  48. }
  49. }
  50.  
  51. <?xml version="1.0" encoding="utf-8"?>
  52. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  53. package="pt.ubi.di.pdm.expermissions1">
  54. <uses-permission
  55. android:name="android.permission.READ_CALL_LOG"></uses-permission>
  56. <application
  57. android:allowBackup="true"
  58. android:icon="@mipmap/ic_launcher"
  59. android:label="@string/app_name"
  60. android:roundIcon="@mipmap/ic_launcher_round"
  61. android:supportsRtl="true"
  62. android:theme="@style/AppTheme">
  63. <activity android:name=".Lastcall">
  64. <intent-filter>
  65. <action android:name="android.intent.action.MAIN" />
  66.  
  67. <category android:name="android.intent.category.LAUNCHER" />
  68. </intent-filter>
  69. </activity>
  70. </application>
  71.  
  72. </manifest>
Add Comment
Please, Sign In to add comment