Question

I'd like to trigger an event when the user changes the phone's profile but I'm not sure how. Idealy, I could catch the a broadcast intent and know when the profile has changed but I haven't been able to find any documentation on this.

If I'm correct, the profile system is not a part of the stock AOSP but Cyanogenmod.

I've trudged through the only two profile-related classes I could find:

The only broadcast intent that I could find was here.

Any idea on how this could be accomplished? My application only targets devices running Cyanogenmod 10.1. This is the profile manager from CyanogenMod to give you a clearer idea of what I'm talking about.

enter image description here

Was it helpful?

Solution 4

As per my discussions with the Cyanogenmod developers, it can be handled by added a BroadcastReceiver for the Intent in ProfileManagerService.java

The issue was that this intent was missing from the ProfileManager.java class and instead existed elsewhere.

The issue for this question can be found on Cyanogenmod's issue tracker.

OTHER TIPS

Not sure whether i am right about what you want,but in my case it works good.Try if it can help you.
I used here 2 buttons to set profile as silent and default mode.Trigger your events when those will activate upon button click.

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final TextView text = (TextView) findViewById(R.id.text1);

    Button silent = (Button) findViewById(R.id.silent);
    Button default = (Button) findViewById(R.id.default);

    final AudioManager mode = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);

    silent.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View v)
        {
            text.setText("The Mobile in Silent Mode"); //i use example case,trigger your event here

            mode.setRingerMode(AudioManager.RINGER_MODE_SILENT);
            Toast.makeText(getBaseContext(), "Silent Mode Activated",Toast.LENGTH_LONG).show()
        }
     });

    default.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View v)
        {
            text.setText("The Mobile in Default Mode"); //trigger your event here

            mode.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
            Toast.makeText(getBaseContext(), "Default Mode Activated", Toast.LENGTH_LONG).show();
         }
     });
 }

Apparently this can also help you..

Since those are two separate environments, I don't think it is possible right now to detect when you switch from one to the other.

How can I trigger an event when the device's profile is changed?

Android does not have any support for this , in other words you can not trigger some event while change the profile .

you can only trigger event when device Ringer mode has change but not for the profile .

even i could not find the profile names of devices and current set profile name which could be the way to make what you are searching for .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top