Activity Starter newbie

Hello !! I am trying to connect to an Android App. This is what the developer of that App sent me:

Intent i = new Intent();
i.setComponent(new ComponentName("com.taidochealthapp", "com.taidochealthapp.service.BluetoothScanningService"));
i.setAction("BluetoothScanningService");
i.putExtra("mac_address","aa:flag_bb:cc:dd:flag_ee:ff");
i.putExtra("device_type","01");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(i);
} else {
startService(i);
}

This is my block:

blocks(1)

Any help is greatly appreciated.

Thank you in advance,

Carlos

you are trying to open another app :thinking:, you should see this tutorial:

https://appinventor.mit.edu/explore/ai2/activity-starter.html

You can't start services with the activity starter component :confused: You might need an extension for that.

Thank you Salman. That's the link I followed to build my block but i think I am missing a parameter or something.

Error: 601
Msg: No corresponded activity was found.

Thank you Mohamed_tamer.

So we can open as App but can not open an App that is running like a Service ? Is this correct ?

Do you know of an extension i can use ?

Thank you,

Carlos

Hello again biesys,

Yes you can start or run apps using the activity starter, but the code you have shared is used to run a service, which is something that the activity starter can do, as its name suggests,it's used to start activities.

It depends on the purpose of your code ( maybe an extension would do the same as you want ), however, there isn't an extension to specifically start services as far as I know, you can find all of the app Inventor extensions in the extension directory:

someone must write an extension especially for that purpose

you could write your own extension and create the functionality yourself...
more information about how to create an extension see the App Inventor Extensions document
however that will be more advanced and will require some Java skills...

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Thank you Taifun.

My app used to "write" to /HTM/ but now it can not. Thats the problem I am having with the third party App, so the developer added "intend". I wonder if this is the same problem I had with Playing Videos and path.

If I can create again my text file in /HTM/ I wont need intend. I use your ext for "file exist" etc but I use File1 to create txt. That stoped working with an Android upgrade a few weeks back.

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

As always Taifun, I thank you for all your help.

Looks like ver nb184a has the solution good until Android 11 is deployed.

By the mean time, setting File1.LegacyMode=True allows me to write again to /HTM

I just tested it and it worked.

My third party app and mine talk via .txt files. After Android 10 upgrade, my app stopped creating /HTM/{n}.txt and that's when i requested third party app to use intend so i can use Activity Started, which i currently use with the browser but as explained here today, it doesnt work with Apps running as a Service. So, read about 184 and 184a and applied LegacyMode=True and it works.

Thank you again,

Carlos

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.