This commit is contained in:
2020-12-01 23:32:28 +08:00
parent 98f0941160
commit e786fd266d
15 changed files with 294 additions and 1 deletions

View File

@@ -14,6 +14,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View File

@@ -0,0 +1,38 @@
package com.coolape.tianrun;
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
public class CallLogInfo {
public String number;
public String date;
public int type;
public CallLogInfo(String number, String date, int type) {
super();
this.number = number;
this.date = date;
this.type = type;
}
public JSONObject toJson(){
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put("number", number);
jsonObject.put("date", date);
/* Call log type for incoming calls.
public static final int INCOMING_TYPE = 1;
Call log type for outgoing calls.
public static final int OUTGOING_TYPE = 2;
Call log type for missed calls.
public static final int MISSED_TYPE = 3;
*/
jsonObject.put("type", type);
return jsonObject;
} catch (JSONException e) {
Log.i("", e.getMessage());
return null;
}
}
}

View File

@@ -0,0 +1,47 @@
package com.coolape.tianrun;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.CallLog;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
public class CallLogUtl {
public static List<CallLogInfo> getCallLog(Context context) {
List<CallLogInfo> infos = new ArrayList<CallLogInfo>();
ContentResolver cr = context.getContentResolver();
Uri uri = CallLog.Calls.CONTENT_URI;
String[] projection = new String[] { CallLog.Calls.NUMBER, CallLog.Calls.DATE,
CallLog.Calls.TYPE };
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd hh:mm:ss");
Cursor cursor = cr.query(uri, projection, null, null, null);
while (cursor.moveToNext()) {
String number = cursor.getString(0);
long date = cursor.getLong(1);
int type = cursor.getInt(2);
infos.add(new CallLogInfo(number, format.format(date), type));
}
cursor.close();
return infos;
}
public static String getCallLogJson(Context context) {
List<CallLogInfo> infos = getCallLog(context);
JSONArray array = new JSONArray();
for(int i=0; i < infos.size(); i++){
array.put(infos.get(i).toJson());
}
return array.toString();
}
}

View File

@@ -216,6 +216,11 @@ public class U3dPlugin {
return mediaPlayer.getProgress();
}
//取得记录记录
public String getCallLog() {
return CallLogUtl.getCallLogJson(UnityPlayer.currentActivity);
}
public static void UnitySendMessage(String CallbackFunc, String retCode,
String orgs) {
if (u3dListener.isEmpty()) {