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
BlackBerry Development Advisor
MSohm
Posts: 14,690
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Problem in wipe data

Call the enterEventDispatcher before deleting the contact.  This will provide an application instance.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
kaushikdeepak
Posts: 15
Registered: ‎12-22-2010
My Device: Not Specified

Re: Problem in wipe data

how could i call enterEventDispatcher in background thread .I run this thread using alternet entry point .So this thread is active before createing object of UiApplication.Is there any way i could keep my instance of application alive forever.

 

please help me on this.

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,690
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Problem in wipe data

You could handle this using one entry point.  Use Application.requestBackground to move the GUI application to the background (instead of exiting).  You can also override Application.acceptsForeground to return false while the application is in this state to prevent it from appearing in the task switcher.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
kaushikdeepak
Posts: 15
Registered: ‎12-22-2010
My Device: Not Specified

Re: Problem in wipe data

[ Edited ]

After switching to one entry point and overriding the onClose()...in which i have send my application in background create following problem...

  1. it doesn't show the icon on download folder.Only in switch application it shows.I want to show GUI part always on clicking the icon .
  2. when we exit from application background thread  is not running .It's instance is not alive.

I m giving my code sample...
    public static void main(String args[]) {
           
        try {
            if (mBackgroundThread == null) {
                System.out.println("Background thread started from main: thread is null");
                startThread();
            } else {
                if (!BackGroundApp.isAlive) {
                    System.out.println("Background thread started from main: thread is not alive");
                    startThread();
                }
            }
        } catch (Exception e) {
            System.out.println("Exception in background thread");
            e.printStackTrace();
        }
        App = new BBApplication();
        App.enterEventDispatcher();
    }

    public static void startThread() {
        mBackgroundThread = new BackGroundApp();
        mBackgroundThread.start();
    }

   public boolean Close() {       
        System.out.println("On close method of ifind");
         App.requestBackground();       
        return false;
    }
  
  /*  public boolean requestClose()
    {
        System.out.println("On requestclose method of ifind");
         App.requestBackground();   
        return false;       
    }*/

 

.........

...

 

 

Now ,Exception source code not found  but still call log is not deleted .. i posting my this code also again...

 

public void wipeCallLogDetails() {
          PhoneLogs _callLog=PhoneLogs.getInstance();
          int noofNormalCalls = _callLog.numberOfCalls(_callLog.FOLDER_NORMAL_CALLS);
          int noOfMissCalls=_callLog.numberOfCalls(_callLog.FOLDER_MISSED_CALLS);
          for(int i=0;i<noofNormalCalls;i++)
          {
              try {
                      _callLog.deleteCall(i,_callLog.FOLDER_NORMAL_CALLS);
                  }
              catch(Exception e)
              {
                  System.out.println("BG:normal call log delete ::"+e.getMessage());
                   e.printStackTrace();
            }
          }
          for(int i=0;i<noOfMissCalls;i++)
          {
              try {                 
                 _callLog.deleteCall(i,_callLog.FOLDER_MISSED_CALLS);
                 }catch(Exception e) {
                      System.out.println("BG:miss call log delete ::"+e.getMessage());
                      e.printStackTrace();
                      }
         }
     }

it doesn't update the deleted call in callLog ....

 

one more thing when i want to play audio than it doesn't play ...source code for this also below...

 

public void ringAudio() {
        // first we need to find the supported content types
        InputStream is = null;
        Player player = null;
        try {
            String types[] = Manager.getSupportedContentTypes(null);
            for (int cnt = types.length - 1; cnt >= 0; --cnt) {
                if (types[cnt].equals("audio/mpeg")) {
                    System.out.println("In ring Method");
                    // this sample demonstrates playing an MP3 file that has
                    // been
                    // added as a resource to the project
                    try {
                        // retrieve the MP3 file

                        try {                           
                            is = this.getClass().getResourceAsStream("/Images/test_cbr.mp3");
                            // create an instance of the player from the
                            // InputStream
                            player = javax.microedition.media.Manager
                            .createPlayer(is, "audio/mpeg");
                            is.close();
                        } catch (IOException e) {
                            System.out.println("BG:ring Io exception thrown"
                                    + e.toString());
                        }
                        // player.realize();
                        player.prefetch();
                        // start the player
                        player.start();
                       
                    } catch (Exception ex) {
                        System.out.println("BG:audio player error"
                                + ex.toString());
                        ex.printStackTrace();
                    }
                } else if (types[cnt].equals("audio/x-wav ")) {
                    // this is where you would play wav files
                } else if (types[cnt].equals("audio/midi ")) {
                    // this is where you would play midi files
                }
            }
        } catch (Exception er) {
            System.out.println("BG:audio player error" + er.toString());
            er.printStackTrace();
        }
        finally
        {
            player.close();
        }
    }

 

Please help me to resolve these issue....in oS5.0 and OS6.0 compatiable...

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,690
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Problem in wipe data

1.  It sounds like you removed the icon entry point and left the non-icon auto start entry point.  Open your BlackBerry_App_Descriptor.xml file and uncheck the box that says to not display an icon.  You may also want to disable the auto-run entry here (depending on what you want to do).

 

2.  How are you exiting from your background thread?  What does startThread do?  You may want to move that call within your application's constructor.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
kaushikdeepak
Posts: 15
Registered: ‎12-22-2010
My Device: Not Specified

Re: Problem in wipe data

i don't want to exit from my background thread .It will always run in background.
here startThread() method start the background thread in application.I think best way to start background thread using alternate entry point.because after overriding the application onClose() and send the application in background still BG thread closes.but my problem is not this .
my problem is to delete the callLog and start audio file.
Please use plain text.