on 03-19-2012 12:35 PM
In the andriod SUP sample demo, i have added a login page where the user has to give the correct login credentials to connect to the SUP server. When the wrong credentials are given , it takes me back to login page. Now when i try to login with valid user credentials, it shows the following error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.infy.cust/com.infy.cust.SUP101SampleActivity}: com.sybase.mobile.ApplicationRuntimeException: The value does not match the current set value. The application identifier can not be changed once set.
I hope this error occurs since the validation of user credentials happens after setting the applicationContext & applicationIdentifier.
So, even when i try to login again with correct user credentials, it throws this error.
Kindly Help me in Solving this issue...
Thanks in Advance...!
// getting the user credentials from Login Page
USERNAME=getIntent().getExtras().getString("key_loginid");
PASSWORD=getIntent().getExtras().getString("key_pass");
private void initializeApplication()
{
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setTitle("on boarding ...");
dialog.setMessage("Please wait while downloading initial data...");
dialog.setIndeterminate(false);
dialog.setProgress(100);
dialog.setCancelable(true);
dialog.show();
new Thread()
{
@Override
public void run()
{
try
{
int count = 0;
while (!initializationDone)
{
dialog.setProgress(++count);
Thread.sleep(100);
if (count == 100)
{
count = 0;
}
}
dialog.cancel();
}
catch (Exception e)
{
dialog.cancel();
}
}
}.start();
// ApplicationContext & ApplicationIdentifier are set here
Application app = Application.getInstance();
app.setApplicationIdentifier("CustomerSample");
app.setApplicationContext(SUP101SampleActivity.this);
new Thread(new Runnable()
{
@Override
public void run()
{
try
{
Application app = Application.getInstance();
CustomerSampleDB.registerCallbackHandler(new CustomerDBCallback());
CustomerSampleDB.setApplication(app);
CustomerSampleDB.getSynchronizationProfile().setServerName(HOST); // Convenience only
ConnectionProperties connProps = app.getConnectionProperties();
LoginCredentials loginCredentials = new LoginCredentials(USERNAME, PASSWORD);
connProps.setLoginCredentials(loginCredentials); //validating usercredentials
connProps.setServerName(HOST);
connProps.setPortNumber(PORT);
if (app.getRegistrationStatus() != RegistrationStatus.REGISTERED)
{
app.registerApplication(TIMEOUT);
}
else
{
app.startConnection(TIMEOUT);
}
if (!CustomerSampleDB.isSynchronized("default"))
{
CustomerSampleDB.disableChangeLog();
CustomerSampleDB.synchronize(); // Initial Synchronize
SynchronizationGroup sg = CustomerSampleDB.getSynchronizationGroup("default");
sg.setEnableSIS(true);
sg.save();
CustomerSampleDB.synchronize();
}
CustomerSampleDB.enableChangeLog();
SUP101SampleActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
adapter = new CustomerListAdapter(SUP101SampleActivity.this);
ListView listView = (ListView) findViewById(R.id.listView1);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id)
{
Intent intent = new Intent(SUP101SampleActivity.this, DetailActivity.class);
intent.putExtra("sk", adapter.getSK(position));
SUP101SampleActivity.this.startActivityForResult(intent, REQUEST_DETAIL);
}
});
}
});
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
initializationDone = true;
}
}
}).start();
}
Hi Yoga,
Your method of using static integer is correct.....!
Also, there is another way...
you can try this ....
instead of the line:
app.setApplicationIdentifier("CustomerSample");
you can use:
if (app.getApplicationIdentifier() == null){
app.setApplicationIdentifier("CustomerSample");
}
this way you wont have the worry of using the static variable...
hope this was useful !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried to use a static integer variable. I hope the issue is solved now.
The static variable is initialised to 0. Set the applicationIdentifier() & applicationContext() only when the value is 0.
When there is an exception bcoz of wrong user credentials, increment the static var by 1 so that the application will not try to set the identifier again when you try to give the correct user credentials again.
Thank you...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.