Android Question Is there a way to detect if your app is running inside of another one?

NeoTechni

Well-Known Member
Licensed User
Longtime User
ie: Daydream settings in particular captures the app

In my app, I don't use the back button to exit the app. I'd like to detect when I'm inside the daydream settings screen, and go directly to the settings screen of my app, as well as allowing the back button to exit. (I'd also like to do that for live wallpaper settings)

Normally I'd assume it's in the starting intent, but nothing showed up...
 

Attachments

  • unnamed.png
    136.2 KB · Views: 159

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can set a settings activity for your daydream.
B4X:
AddApplicationText(<service
  android:name="anywheresoftware.b4a.objects.DreamServiceWrapper"
  android:exported="true"
  android:label="Dream Service Example">
  <intent-filter>
  <action android:name="android.service.dreams.DreamService" />
  <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
   <meta-data
  android:name="android.service.dream"
  android:resource="@xml/dream" />
  </service>)
 CreateResource(xml, dream.xml, <dream xmlns:android="http://schemas.android.com/apk/res/android"
 android:settingsActivity="b4a.example1/.settingsactivity" />)

You need to change the settingsActivity value.
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
I already did that. But my app is all one activity. So I don't know if it's been summoned by the settings app or not.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…