Page 4 of 4

Re: DIY-Actions/Triggers: Start Activity, General Broadcast, ...

Posted: 01 Aug 2019 05:00
by Rafi4
hi anuraag
after a long time I have got right solution.
thanks a lot. I want to delete files using start activity action. I am trying. but no success. any suggestions?

thanks a lot for post. from record4

Re: DIY-Actions/Triggers: Start Activity, General Broadcast, ...

Posted: 01 Aug 2019 05:23
by anuraag
Use delete files action instead. Set Files to Variable {file_path}.

Edit: example flow.
I have removed explicit component from start activiry. This will work for any file type.
http://automagic4android.com/flow.php?i ... 2df6750845

Re: DIY-Actions/Triggers: Start Activity, General Broadcast, ...

Posted: 01 Aug 2019 06:28
by Rafi4
hi anuraag
working amazing. thank a lot.

thanks from record4

Re: DIY-Actions/Triggers: Start Activity, General Broadcast, ...

Posted: 08 Oct 2019 13:55
by Rafi4
Hi
How can I get calendar event id in below {event_id}
to edit calendar event using start activity action.

Code: Select all

content://com.android.calendar/events/{event_id}
How can I get calendar events list?


Thanks from From record4

Re: DIY-Actions/Triggers: Start Activity, General Broadcast, ...

Posted: 09 Oct 2019 18:41
by Desmanto
Use query content provider, from example choose list all calendar events. Change the triggertime on both braces to the specific range of time you need. You can prepare it in another variable first. Or you can just addDays directly to the triggertime

Code: Select all

content://com.android.calendar/instances/when/{triggertime}/{addDays(triggertime,30)}
This will show calendar events from now to 30 days later.

At the projection, check any field you want to use. In this case, of course you must check _id.
Change the result type to the type you want. You might want to use Table type, so you get nested list you can work with. Use debug dialog to check the value afterward.

Re: DIY-Actions/Triggers: Start Activity, General Broadcast, ...

Posted: 10 Oct 2019 08:04
by Rafi4
Hi Desmanto
Thanks a lot. Also I want to know is there any way to delete events.

from record4

Re: DIY-Actions/Triggers: Start Activity, General Broadcast, ...

Posted: 11 Oct 2019 17:29
by Desmanto
I don't think there is a way to delete it, since it is query content provider, not for delete.

Re: DIY-Actions/Triggers: Start Activity, General Broadcast, ...

Posted: 12 Oct 2019 00:20
by anuraag
Desmanto wrote:
11 Oct 2019 17:29
I don't think there is a way to delete it, since it is query content provider, not for delete.
Using java code it can be deleted. You can get eventID from query content provider.

Code: Select all

eventID = 201;

cr = callJavaMethod(getContext(), "android.content.Context", "getContentResolver()");
deleteUri = callJavaStaticMethod("android.content.ContentUris", "withAppendedId(android.net.Uri, long)", getJavaStaticField("android.provider.CalendarContract$Events", "CONTENT_URI"), eventID);
rows = callJavaMethod(cr, "android.content.ContentResolver", "delete(android.net.Uri, java.lang.String, java.lang.String[])", deleteUri, null, null)

Re: DIY-Actions/Triggers: Start Activity, General Broadcast, ...

Posted: 12 Oct 2019 01:27
by Rafi4
Hi anuraag
Working Amazing. But it delete repeated events also.

For example. I have created an event to remind me every day title named "Call to my bro" id is for example 444. If I delete this event id 444 it was deleting upcoming events also named "Call to my bro". How can I prevent this?

I think that I have explained better.

Thanks from record4

Re: DIY-Actions/Triggers: Start Activity, General Broadcast, ...

Posted: 13 Oct 2019 03:21
by anuraag
@Rafi4
This code is working.
Get first below 6 variables from queryContentProvider.

Code: Select all

event_id = "";
calendar_timezone = "";
allDay = "";
begin = "";
_sync_id = "";
rrule = "";

cr = callJavaMethod(getContext(), "android.content.Context", "getContentResolver()");

if (rrule == null) {
	uri = callJavaStaticMethod("android.content.ContentUris", "withAppendedId(android.net.Uri, long)", getJavaStaticField("android.provider.CalendarContract$Events", "CONTENT_URI"), event_id);
	callJavaMethod(cr, "android.content.ContentResolver", "delete(android.net.Uri, java.lang.String, java.lang.String[])", uri, null, null)
} else {
	values = callJavaConstructor("android.content.ContentValues", "ContentValues()");
	callJavaMethod(values, "android.content.ContentValues", "put(java.lang.String, java.lang.String)", getJavaStaticField("android.provider.CalendarContract$EventsColumns", "EVENT_TIMEZONE"), calendar_timezone);
	callJavaMethod(values, "android.content.ContentValues", "put(java.lang.String, java.lang.String)", getJavaStaticField("android.provider.CalendarContract$EventsColumns", "ALL_DAY"), allDay);
	callJavaMethod(values, "android.content.ContentValues", "put(java.lang.String, java.lang.String)", getJavaStaticField("android.provider.CalendarContract$EventsColumns", "DTSTART"), begin);
	callJavaMethod(values, "android.content.ContentValues", "put(java.lang.String, java.lang.String)", getJavaStaticField("android.provider.CalendarContract$EventsColumns", "ORIGINAL_SYNC_ID"), _sync_id);
	callJavaMethod(values, "android.content.ContentValues", "put(java.lang.String, java.lang.String)", getJavaStaticField("android.provider.CalendarContract$EventsColumns", "ORIGINAL_INSTANCE_TIME"), begin);
	callJavaMethod(values, "android.content.ContentValues", "put(java.lang.String, java.lang.String)", getJavaStaticField("android.provider.CalendarContract$EventsColumns", "STATUS"), getJavaStaticField("android.provider.CalendarContract$EventsColumns", "STATUS_CANCELED"));

	uri = callJavaStaticMethod("android.net.Uri", "withAppendedPath(android.net.Uri, java.lang.String)", getJavaStaticField("android.provider.CalendarContract$Events", "CONTENT_EXCEPTION_URI"), event_id);
	callJavaMethod(cr, "android.content.ContentResolver", "insert(android.net.Uri, android.content.ContentValues)", uri, values);
}
Source
https://github.com/LineageOS/android_pa ... .java#L361

You should also use Request sync action of Automagic to reflect changes in Google calendar.