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

Post your questions and help other users.

Moderator: Martin

User avatar
Rafi4
Posts: 220
Joined: 01 Dec 2017 05:23

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

Post by Rafi4 » 01 Aug 2019 05:00

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
Samsung Galaxy j2 non rooted.
Android 5.1.1

anuraag
Posts: 273
Joined: 24 Jan 2015 02:06

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

Post by anuraag » 01 Aug 2019 05:23

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

User avatar
Rafi4
Posts: 220
Joined: 01 Dec 2017 05:23

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

Post by Rafi4 » 01 Aug 2019 06:28

hi anuraag
working amazing. thank a lot.

thanks from record4
Samsung Galaxy j2 non rooted.
Android 5.1.1

User avatar
Rafi4
Posts: 220
Joined: 01 Dec 2017 05:23

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

Post by Rafi4 » 08 Oct 2019 13:55

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
Samsung Galaxy j2 non rooted.
Android 5.1.1

User avatar
Desmanto
Posts: 2036
Joined: 21 Jul 2017 17:50

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

Post by Desmanto » 09 Oct 2019 18:41

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190829, Pie 9.0, Rooted.

User avatar
Rafi4
Posts: 220
Joined: 01 Dec 2017 05:23

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

Post by Rafi4 » 10 Oct 2019 08:04

Hi Desmanto
Thanks a lot. Also I want to know is there any way to delete events.

from record4
Samsung Galaxy j2 non rooted.
Android 5.1.1

User avatar
Desmanto
Posts: 2036
Joined: 21 Jul 2017 17:50

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

Post by Desmanto » 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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190829, Pie 9.0, Rooted.

anuraag
Posts: 273
Joined: 24 Jan 2015 02:06

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

Post by anuraag » 12 Oct 2019 00:20

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)

User avatar
Rafi4
Posts: 220
Joined: 01 Dec 2017 05:23

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

Post by Rafi4 » 12 Oct 2019 01:27

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
Samsung Galaxy j2 non rooted.
Android 5.1.1

anuraag
Posts: 273
Joined: 24 Jan 2015 02:06

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

Post by anuraag » 13 Oct 2019 03:21

@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.

Post Reply