Skip to content

Commit 42fe98f

Browse files
committed
Added Intents and Content Provider basic implementation
0 parents  commit 42fe98f

File tree

88 files changed

+2454
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2454
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx

ContentProvider1_Implementation/.idea/codeStyles/Project.xml

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ContentProvider1_Implementation/.idea/gradle.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ContentProvider1_Implementation/.idea/jarRepositories.xml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ContentProvider1_Implementation/.idea/misc.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ContentProvider1_Implementation/.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 30
5+
buildToolsVersion "29.0.3"
6+
7+
defaultConfig {
8+
applicationId "com.example.contentprovider1_implementation"
9+
minSdkVersion 19
10+
targetSdkVersion 30
11+
versionCode 1
12+
versionName "1.0"
13+
14+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15+
}
16+
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
}
24+
25+
dependencies {
26+
implementation fileTree(dir: "libs", include: ["*.jar"])
27+
implementation 'androidx.appcompat:appcompat:1.2.0'
28+
implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
29+
testImplementation 'junit:junit:4.12'
30+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
31+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
32+
33+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.contentprovider1_implementation;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.example.contentprovider1_implementation", appContext.getPackageName());
25+
}
26+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.contentprovider1_implementation">
4+
5+
<uses-permission android:name="android.permission.READ_CONTACTS" />
6+
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
7+
<uses-permission android:name="android.permission.READ_PROFILE" />
8+
<uses-permission android:name="android.permission.WRITE_PROFILE" />
9+
10+
<application
11+
android:allowBackup="true"
12+
android:icon="@mipmap/ic_launcher"
13+
android:label="@string/app_name"
14+
android:roundIcon="@mipmap/ic_launcher_round"
15+
android:supportsRtl="true"
16+
android:theme="@style/AppTheme">
17+
<activity android:name=".MainActivity">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
</activity>
24+
<activity android:name=".Activity_Contacts" />
25+
26+
</application>
27+
28+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.example.contentprovider1_implementation;
2+
3+
import android.content.ContentResolver;
4+
import android.database.Cursor;
5+
import android.net.Uri;
6+
import android.os.Bundle;
7+
import android.provider.ContactsContract;
8+
import android.view.View;
9+
import android.widget.TextView;
10+
import android.widget.Toast;
11+
12+
import androidx.appcompat.app.AppCompatActivity;
13+
14+
public class Activity_Contacts extends AppCompatActivity {
15+
ContentResolver contentResolver ;
16+
TextView resultTextView ;
17+
18+
@Override
19+
protected void onCreate(Bundle savedInstanceState) {
20+
super.onCreate(savedInstanceState);
21+
setContentView(R.layout.activity_contacts);
22+
getReferences();
23+
24+
contentResolver = getContentResolver() ;
25+
}
26+
27+
private void getReferences(){
28+
resultTextView = findViewById(R.id.activityContentProvider_TextView_Result) ;
29+
30+
}
31+
32+
public void showAllContacts(View v){
33+
Uri tableUri = ContactsContract.Contacts.CONTENT_URI ; // => Uri.parse("content://user_dictionary/words") ;
34+
String[] arrayOfColumnNames = {
35+
ContactsContract.Contacts._ID,
36+
ContactsContract.Contacts.DISPLAY_NAME,
37+
// ContactsContract.CommonDataKinds.Phone.NUMBER,
38+
39+
} ;
40+
41+
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " DESC" ;
42+
43+
Cursor cursor = contentResolver.query(tableUri, arrayOfColumnNames, null, null, sortOrder) ;
44+
Toast.makeText(this, "Count is " + cursor.getCount(), Toast.LENGTH_SHORT).show() ;
45+
while(cursor.moveToNext()){
46+
String a0 = cursor.getString(0) ;
47+
String a1 = cursor.getString(1) ;
48+
String a2 = "" ; // cursor.getString(2) ;
49+
50+
51+
resultTextView.append(a0 + " - " + a1 + " - " + a2 + "\n");
52+
}
53+
cursor.close();
54+
}
55+
56+
57+
58+
59+
60+
61+
}

0 commit comments

Comments
 (0)