android-contentresolver

Multi connection via bluetooth in android

不问归期 提交于 2019-12-01 01:13:13
Hy , We are working on the android multiplayer game via bluetooth. It is a multiplayer LUDO game in which 4 player connect to each other and play the game. We are stuck in connection with the 3rd and 4th player connection. private OnMaxConnectionsReachedListener maxConnectionsListener = new OnMaxConnectionsReachedListener() { public void OnMaxConnectionsReached() { } }; private OnIncomingConnectionListener connectedListener = new OnIncomingConnectionListener() { public void OnIncomingConnection(String device) { //rivalDevice = device; if(index < 1000) { clients[index] = device; index++; Log.d(

Multi connection via bluetooth in android

时间秒杀一切 提交于 2019-11-30 20:51:49
问题 Hy , We are working on the android multiplayer game via bluetooth. It is a multiplayer LUDO game in which 4 player connect to each other and play the game. We are stuck in connection with the 3rd and 4th player connection. private OnMaxConnectionsReachedListener maxConnectionsListener = new OnMaxConnectionsReachedListener() { public void OnMaxConnectionsReached() { } }; private OnIncomingConnectionListener connectedListener = new OnIncomingConnectionListener() { public void

Batch Delete items with Content Provider in Android

别来无恙 提交于 2019-11-30 18:56:08
I'm trying to batch delete some items in a table. String ids = { "1", "2", "3" }; mContentResolver.delete(uri, MyTables._ID + "=?", ids); However I keep getting this following error java.lang.IllegalArgumentException: Too many bind arguments. 3 arguments were provided but the statement needs 1 arguments. The error occurs because you have a single placeholder (?) in your where clause, while you pass three arguments. You should do: String ids = { "1", "2", "3" }; mContentResolver.delete(uri, MyTables._ID + "=? OR " + MyTables._ID + "=? OR " + MyTables._ID + "=?", ids); I do not know if SQLite

ContentResolver doesn't contain just created image in an immediate query after creation of file

╄→尐↘猪︶ㄣ 提交于 2019-11-30 16:30:39
I'm using this code to copy an image using documentFile.createFile() private void newcopyFile(File fileInput, String outputParentPath, String mimeType, String newFileName) { DocumentFile documentFileGoal = DocumentFile.fromTreeUri(this, treeUri); String[] parts = outputParentPath.split("\\/"); for (int i = 3; i < parts.length; i++) { if (documentFileGoal != null) { documentFileGoal = documentFileGoal.findFile(parts[i]); } } if (documentFileGoal == null) { Toast.makeText(MainActivity.this, "Directory not found", Toast.LENGTH_SHORT).show(); return; } DocumentFile documentFileNewFile =

Android : Get recently added media in Android Device similarly to File Manager

半腔热情 提交于 2019-11-30 16:13:23
I am working on an application in which I have to notify user as soon as a new image, video, audio or apk is inserted by the user by any means (whether he downloads it or transfer it),similar to what File Manager application do.I don't know where to start from. Thanks Here is my complete code to notify user when a new media (image, audio or video) is added into the device. It might help someone.Also, I am displaying push notifications as soon as new media is added. EDITED (issues resolved are below) 1.Notify user only when media is added,not deleted. public class MediaTrackerService extends

Android : Get recently added media in Android Device similarly to File Manager

自闭症网瘾萝莉.ら 提交于 2019-11-30 16:09:58
问题 I am working on an application in which I have to notify user as soon as a new image, video, audio or apk is inserted by the user by any means (whether he downloads it or transfer it),similar to what File Manager application do.I don't know where to start from. Thanks 回答1: Here is my complete code to notify user when a new media (image, audio or video) is added into the device. It might help someone.Also, I am displaying push notifications as soon as new media is added. EDITED (issues

A final answer on how to get Exif data from URI

ぐ巨炮叔叔 提交于 2019-11-30 12:26:48
问题 This topic has been discussed in lots of questions here, with mostly different results and, due to API changes and different types of URIs, no definitive answer . I don’t have an answer myself, but let’s talk about it. The ExifInterface has a single constructor that accepts a filePath . That itself is annoying, as it is discouraged now to rely on paths - you should rather use Uri s and ContentResolver . OK. Our Uri named uri can be retrieved from the intent in onActivityResult (if you pick

Trouble writing internal memory android

可紊 提交于 2019-11-30 07:35:00
void launchImageCapture(Activity context) { Uri imageFileUri = context.getContentResolver() .insert(Media.INTERNAL_CONTENT_URI, new ContentValues()); m_queue.add(imageFileUri); Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri); context.startActivityForResult(i, ImportActivity.CAMERA_REQUEST); } The above code, which has always worked, is now generating this exception for me at insert(). java.lang.UnsupportedOperationException: Writing to internal storage is not supported. at com.android.providers.media

How to get contacts in order of their upcoming birthdays?

烂漫一生 提交于 2019-11-30 07:00:56
问题 I have code to read contact details and to read birthdays. But how do I get a list of contacts in order of their upcoming birthday? For a single contact identified by id , I get details and birthday like this: Cursor c = null; try { Uri uri = ContentUris.withAppendedId( ContactsContract.Contacts.CONTENT_URI, id); c = ctx.getContentResolver().query(uri, null, null, null, null); if (c != null) { if (c.moveToFirst()) { DatabaseUtils.cursorRowToContentValues(c, data); } } c.close(); // read

Batch Delete items with Content Provider in Android

Deadly 提交于 2019-11-30 03:38:19
问题 I'm trying to batch delete some items in a table. String ids = { "1", "2", "3" }; mContentResolver.delete(uri, MyTables._ID + "=?", ids); However I keep getting this following error java.lang.IllegalArgumentException: Too many bind arguments. 3 arguments were provided but the statement needs 1 arguments. 回答1: The error occurs because you have a single placeholder (?) in your where clause, while you pass three arguments. You should do: String ids = { "1", "2", "3" }; mContentResolver.delete