Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 21
Registered: ‎03-26-2012
My Device: balck berry 9550
Accepted Solution

detect device mode

i play ringtome  in my application but its work even the  phone is in silent mode so how to dectet the device  mode if  it  vibration silent or  normal  mode any help with that thx on advance

Contributor
Posts: 21
Registered: ‎03-26-2012
My Device: balck berry 9550

Re: detect device mode

this is  the  code  i used

  InputStream stream = (InputStream)this.getClass()
  .getResourceAsStream("/storm.mp3");
  p = Manager.createPlayer(stream, "audio/x-wav");
  p.realize();
  p.prefetch();
  p.start();

i want to know the  mode to the device to call rthis methode only when is normal and use laert vibrate when is in vibrate did anyone have any idea how i can solve that .

Developer
Posts: 16,495
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: detect device mode

you can use the notification api to integrate with the profiles.

the profiles API is only available since 7.1, which is quite limiting.
http://www.blackberry.com/developers/docs/7.1.0api/net/rim/blackberry/api/profiles/Profiles.html
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 21
Registered: ‎03-26-2012
My Device: balck berry 9550

Re: detect device mode

my application based on api 5 and i cant change to api7

but i find this code can u tell me how i can use  it to detect that in silent mode or vibrate  do not play the  ringtone

    

      private void openProfiles() {
  int handle = CodeModuleManager
    .getModuleHandle("net_rim_bb_profiles_app");
  ApplicationDescriptor[] appDescr = CodeModuleManager
    .getApplicationDescriptors(handle);
  if (appDescr.length > 0) {
   try {
    ApplicationManager.getApplicationManager().runApplication(
      appDescr[0]);
   } catch (ApplicationManagerException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
  }
 }

Developer
Posts: 16,495
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: detect device mode

the notification API is available on all OS versions and is best practice, any particular reason why you don't want to use it?
see http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/notification/NotificationsMana... and the developer guide for details.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Trusted Contributor
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified

Re: detect device mode

 :Shifty: :Shifty: :Shifty:

don't waste your time,

 

this is not possible on os versions less than os 7.1,  no api can make this also i haven't seen any Blackberry application do this yet.

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: detect device mode

To check if is in silent mode, you can try (haven't tested my self) this:

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/Alert.html#getVolume()

 

and compare the result to zero.

 

Hope that helps,

 

E.

Trusted Contributor
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified

Re: detect device mode

when the device mode is set to (all alerts off), it return sound level 100 ?!, although it should give us 0

Developer
Posts: 16,495
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: detect device mode

the alert level is independent from the notification system i guess.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Trusted Contributor
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified

Re: detect device mode

tha thread main questuin was about getting the device mode which is not possible, not getting alert level