cancel
Showing results for 
Search instead for 
Did you mean: 

Android SUP101Sample app is getting crashed when i close the app and reopen

Former Member
0 Kudos

Hi,

I have downloaded the Sybase Unwired Platfom 2.1 ESD #1, with sample code. iam able to sync the android application to get the data from the MBO data source (DS). But whenever i close the application, the application throws an error and whenever i re-open the application second time it crashes with force close.

The following error/Exceptions i get when i close the

android application

02-22 18:54:33.655: E/ActivityThread(549): Activity com.sybase.sup.samples.objectapi.SUP101SampleActivity has leaked IntentReceiver com.sybase.mo.MessagingService$MoTelephonyListener$1@44fb19a8 that was originally registered here. Are you missing a call to unregisterReceiver()?

When i re-open the app again, the below exception is shown with force close

02-22 18:57:21.004: E/AndroidRuntime(549):

java.lang.RuntimeException: Unable to start activity ComponentInfo {com.sybase.sup.samples.objectapi/com.sybase.sup.samples.objectapi.SUP101SampleActivity}:

com.sybase.mobile.ApplicationRuntimeException: The value does not match the current set value. The application identifier cannot be changed once set.

Please let me know which API i need to use to unregister the application to ensure that the app does not crash. Also provide any appropriate working sample android code other than the one which is available in the Sybase infocenter site.

please i need some urgent help in this regard, please...

Thanks,

Ushasri

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ushasri

Actually I'm facing the same problem concerning the sample code provided in the tutorials.

I already fixed the exception being thrown when re-opening the app by providing the application from setting the application identifier twice. Therefore I simply created a new boolean which is set to "true" after the initialization. The initialization-method is called in onCreate, but only if the boolean is still "false". As the application identifier is obviously restricted to be set once I guess this is the only possibility to manage this problem.

The IntentReceiver is a problem, it seems as if it is created when setting the application context (app.setApplicationContext(context)) so as a result the receiver is not callable in the specific activity and cannot be removed. I am really curious how it is possible to solve this problem - maybe you found a solution already, otherwise I would appreciate if someone else could leave a hint here. Thx in advance!

Best regards

Clyde

Former Member
0 Kudos

Hi Clyde,

Thanks for the reply, that IntentReceiver problem can be solved bye replacing app.setApplicationContext(context)) with app.setApplicationContext(getApplicationContect());

Thanks,

Ushasri

Former Member
0 Kudos

Many thanks, this is exactly what I needed!

Hope your Application is running fine by now as well.

Thx again, best regards,

Clyde

Vlad
Advisor
Advisor
0 Kudos

Thank you for the solution. I tried it, but it did not help me. I played with multiple solutions, but found the simplest one that works fine for me:

Since the problem occurs in the line:

app.setApplicationIdentifier(APPLICATION_ID);

I decided to change it a little:

if (app.getApplicationIdentifier() == null)

     app.setApplicationIdentifier(APPLICATION_ID);

The solution is quite stupid, but it works when you rotate the screen. The application does not crash anymore.

update:

Ha-ha! To be honest, this is probably the most right solution. Because if you examine the Application.setApplicationIdentifier method, you will find following lines:

  public void setApplicationIdentifier(String value) {

    if (this.applicationIdentifier != null) {

      throw new ApplicationRuntimeException("The value does not match the current set value. The application identifier can not be changed once set.");

    }

Now you understood, why the exception was thrown

Kind regards,

Vlad

Former Member
0 Kudos

I was facing the similar issues of Second time app was getting crash and came to know that it is trying to register the application again hence

if(TextUtils.isEmpty(app.getApplicationIdentifier())) {

                   app.setApplicationIdentifier("SUP101");

  }

I have added above line after

Application app = Application.getInstance(); in the SUP101SampleActivity.java file and

from AndroidManifest.xml file removed main and launcher intent for detail activity

Former Member
0 Kudos

Thank you Former Member

Your Logic working for me as well...


Regards,

V B Jampana