How to get Contacts Presence status from LinphoneFriend? - android

I have uses linphone library latest version. I want to display sip contacts status. here is my code.
LinphoneFriend[] friends = LinphoneManager.getLc().getFriendList();
if (!ContactsManager.getInstance().isContactPresenceDisabled() && friends != null && contact.hasAddress()) {
friendStatus.setVisibility(View.VISIBLE);
String friendSipAddress = "";
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
if (noa.isSIPAddress()) {
friendSipAddress = noa.getValue();
}
}
LinphoneFriend friend = null;
for (int i = 0; i < friends.length; i++) {
Log.e("Friend","Addr " + friends[i].getAddress().asStringUriOnly());
Log.e("Friend","Name " + friends[i].getAddress().getDisplayName());
if (friends[i].getAddress().asStringUriOnly().equalsIgnoreCase(friendSipAddress)) {
friend = friends[i];
break;
}
}
if(friend!=null) {
PresenceModel presenceModel = friend.getPresenceModel();
if (presenceModel != null) {
//PresenceActivityType presenceActivity = friends[0].getPresenceModel().getActivity().getType();
PresenceActivityType presenceActivity = presenceModel.getActivity().getType();
android.util.Log.e("Linphone",friend.getName()+" " + presenceActivity);
if (presenceActivity == PresenceActivityType.Online) {
friendStatus.setImageResource(R.drawable.led_connected);
} else if (presenceActivity == PresenceActivityType.Busy) {
friendStatus.setImageResource(R.drawable.led_error);
} else if (presenceActivity == PresenceActivityType.Away) {
friendStatus.setImageResource(R.drawable.led_inprogress);
} else if (presenceActivity == PresenceActivityType.OnThePhone) {
friendStatus.setImageResource(R.drawable.on_phone);
} else if (presenceActivity == PresenceActivityType.Offline) {
friendStatus.setImageResource(R.drawable.led_disconnected);
} else {
friendStatus.setImageResource(R.drawable.led_disconnected);
}
} else {
friendStatus.setImageResource(R.drawable.led_error);
//Log.e("Linphone", "led_error");
}
} else {
//Log.e("Friend","friend null");
}
} else {
Log.e("Friend","friend visibility gone");
friendStatus.setVisibility(View.INVISIBLE);
}
But LinphoneFriend object always give null PresenceModel. How to get presencemodel with status from linphonefriend?

Related

how to integrate google assistant in android for native application?

I have gone through many tutorials with API.AI But didn't get the exact solution. My requirement is simply:- user will send some command using voice or text and get that commands in my application and execute some method.
API.AI
Actions on Google
Tutorial of Google Assistant
First of all you need to train your model on API.AI to respond upon some text given to the model.
Some code with API.AI FYI:
//Initialize Service
private void initService(final LanguageConfig selectedLanguage) {
try {
final AIConfiguration.SupportedLanguages lang = AIConfiguration.SupportedLanguages.fromLanguageTag(selectedLanguage.getLanguageCode());
final AIConfiguration config = new AIConfiguration(selectedLanguage.getAccessToken(),
lang,
AIConfiguration.RecognitionEngine.System);
aiDataService = new AIDataService(this, config);
} catch (Exception e) {
e.printStackTrace();
}
}
//Send request method where you can put user typed text to get the result from API.AI
private void sendRequest(final String textToSend, final int flag) {
Log.w(TAG, "Sending" + textToSend);
final AsyncTask<String, Void, AIResponse> task = new AsyncTask<String, Void, AIResponse>() {
private AIError aiError;
#Override
protected void onPreExecute() {
super.onPreExecute();
showHideProgressBar(true);
if (mVoiceRecorder != null) {
mVoiceRecorder.pauseRecording();
}
}
#Override
protected AIResponse doInBackground(final String... params) {
final AIRequest request = new AIRequest();
String query = params[0];
String event = params[1];
if (!TextUtils.isEmpty(query))
request.setQuery(query);
if (!TextUtils.isEmpty(event)) {
request.setEvent(new AIEvent(event));
}
final String contextString = params[2];
RequestExtras requestExtras = null;
if (!TextUtils.isEmpty(contextString)) {
final List<AIContext> contexts = Collections.singletonList(new AIContext(contextString));
requestExtras = new RequestExtras(contexts, null);
}
try {
Log.i("API AI Request", "" + request.toString());
return aiDataService.request(request, requestExtras);
} catch (final AIServiceException e) {
aiError = new AIError(e);
return null;
}
}
#Override
protected void onPostExecute(final AIResponse response) {
showHideProgressBar(false);
speechSentStatus = false;
okSentStatus = false;
if (response != null) {
onResult(response, flag, textToSend);
} else {
onError(aiError);
}
}
};
if (flag == OPEN_COMPLAIN_CODE) {
task.execute("", Config.Events[0], Config.Events[0]);
} else if (flag == OPEN_DIAGNOSIS_CODE) {
task.execute("", Config.Events[1], Config.Events[1]);
} else if (flag == Constants.OPEN_MEDICATION_CODE) {
task.execute("", Config.Events[2], Config.Events[2]);
} else if (flag == Constants.OPEN_LABTEST_CODE) {
task.execute("", Config.Events[3], Config.Events[3]);
} else if (flag == Constants.COMPLAINTS_ADDED) {
task.execute("", Config.Events[0], Config.Events[0]);
} else if (flag == Constants.DIAGNOSIS_ADDED) {
task.execute("", Config.Events[1], Config.Events[1]);
} else {
task.execute(textToSend, null, "");
}
}
//Based on result you can handle the business logic
private void onResult(final AIResponse response, final int flag, final String textToSend) {
runOnUiThread(new Runnable() {
#Override
public void run() {
apiAiResponseCounter = apiAiResponseCounter + 1;
isLast = false;
final Result result = response.getResult();
Log.w(TAG, "" + result.getFulfillment().getSpeech());
if (flag == Constants.COMPLAINTS_ADDED) {
//method you want to execute on receiving certain text from model
send(textToSend.toLowerCase(), DONTTEXT);
} else if (flag == Constants.DIAGNOSIS_ADDED) {
send(textToSend.toLowerCase(), DONTTEXT);
} else {
String error = "";
final String speech = result.getFulfillment().getSpeech();
if (speech.contains("?")) {
if (!result.getAction().equalsIgnoreCase("input.unknown")) {
if (result.getAction().equalsIgnoreCase(Config.Actions[5]) && result.isActionIncomplete() == false) {
//DONOTHING
} else {
digiMessage(speech, YESNO);
}
} else {
digiMessage(speech, ChatMessageAdapter.OTHER_MESSAGE);
}
} else {
if (speech.equalsIgnoreCase("Please help me the intake duration of the medication")) {
digiMessage(speech, ChatMessageAdapter.DURATION);
} else if (speech.equalsIgnoreCase("Please provide the daily routine for the medication intake")) {
digiMessage(speech, ChatMessageAdapter.FREQUENCY);
} else {
digiMessage(speech, ChatMessageAdapter.OTHER_MESSAGE);
}
}
if (result.getAction().equalsIgnoreCase(Config.Actions[4]) || result.getAction().equalsIgnoreCase(Config.Actions[5])) {
if (result.isActionIncomplete() == true) {
playSpeech(speech);
} else {
speechBuffer = "";
speechBuffer = speech;
}
} else {
if (result.getAction().equalsIgnoreCase(Config.Actions[11])) {
isLast = true;
if (mVoiceRecorder != null) {
stopVoiceRecording();
}
} else {
playSpeech(speech);
}
}
}
}
});
if (flag == Constants.COMPLAINTS_ADDED || flag == Constants.DIAGNOSIS_ADDED) {
Log.w(TAG, "Skipped");
} else {
inflateUI(response.getResult());
}
}

Watson unity android bad recognition

Guys I'm using Unity and Watson to make and vr app that accepts voice commands. I'm using the ExampleStreaming.cs provided with the asset but the recognition is terrible. I change the language model to Portuguese on the code. I'm using Samsung galaxy s7 on gear vr with the mic plugged in. I guess the app is using the cellphone mic and not the plugged one. Any help here.
Here's the code
private int _recordingRoutine = 0;
private string _microphoneID = null;
private AudioClip _recording = null;
private int _recordingBufferSize = 1;
private int _recordingHZ = 22050;
private SpeechToText _service;
public GolemController GolemControllerObj;
void Start()
{
LogSystem.InstallDefaultReactors();
Runnable.Run(CreateService());
}
private IEnumerator CreateService()
{
// Create credential and instantiate service
Credentials credentials = null;
if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password))
{
// Authenticate using username and password
credentials = new Credentials(_username, _password, _serviceUrl);
}
else if (!string.IsNullOrEmpty(_iamApikey))
{
// Authenticate using iamApikey
TokenOptions tokenOptions = new TokenOptions()
{
IamApiKey = _iamApikey,
IamUrl = _iamUrl
};
credentials = new Credentials(tokenOptions, _serviceUrl);
// Wait for tokendata
while (!credentials.HasIamTokenData())
yield return null;
}
else
{
throw new WatsonException("Please provide either username and password or IAM apikey to authenticate the service.");
}
_service = new SpeechToText(credentials);
_service.StreamMultipart = true;
_service.RecognizeModel="pt-BR_BroadbandModel";
Active = true;
StartRecording();
}
public bool Active
{
get { return _service.IsListening; }
set
{
if (value && !_service.IsListening)
{
_service.DetectSilence = true;
_service.EnableWordConfidence = true;
_service.EnableTimestamps = true;
_service.SilenceThreshold = 0.01f;
_service.MaxAlternatives = 0;
_service.EnableInterimResults = true;
_service.OnError = OnError;
_service.InactivityTimeout = -1;
_service.ProfanityFilter = false;
_service.SmartFormatting = true;
_service.SpeakerLabels = false;
_service.WordAlternativesThreshold = null;
_service.StartListening(OnRecognize, OnRecognizeSpeaker);
}
else if (!value && _service.IsListening)
{
_service.StopListening();
}
}
}
private void StartRecording()
{
if (_recordingRoutine == 0)
{
UnityObjectUtil.StartDestroyQueue();
_recordingRoutine = Runnable.Run(RecordingHandler());
}
}
private void StopRecording()
{
if (_recordingRoutine != 0)
{
Microphone.End(_microphoneID);
Runnable.Stop(_recordingRoutine);
_recordingRoutine = 0;
}
}
private void OnError(string error)
{
Active = false;
Log.Debug("ExampleStreaming.OnError()", "Error! {0}", error);
}
private IEnumerator RecordingHandler()
{
Log.Debug("ExampleStreaming.RecordingHandler()", "devices: {0}", Microphone.devices);
_recording = Microphone.Start(_microphoneID, true, _recordingBufferSize, _recordingHZ);
yield return null; // let _recordingRoutine get set..
if (_recording == null)
{
StopRecording();
yield break;
}
bool bFirstBlock = true;
int midPoint = _recording.samples / 2;
float[] samples = null;
while (_recordingRoutine != 0 && _recording != null)
{
int writePos = Microphone.GetPosition(_microphoneID);
if (writePos > _recording.samples || !Microphone.IsRecording(_microphoneID))
{
Log.Error("ExampleStreaming.RecordingHandler()", "Microphone disconnected.");
StopRecording();
yield break;
}
if ((bFirstBlock && writePos >= midPoint)
|| (!bFirstBlock && writePos < midPoint))
{
// front block is recorded, make a RecordClip and pass it onto our callback.
samples = new float[midPoint];
_recording.GetData(samples, bFirstBlock ? 0 : midPoint);
AudioData record = new AudioData();
record.MaxLevel = Mathf.Max(Mathf.Abs(Mathf.Min(samples)), Mathf.Max(samples));
record.Clip = AudioClip.Create("Recording", midPoint, _recording.channels, _recordingHZ, false);
record.Clip.SetData(samples, 0);
_service.OnListen(record);
bFirstBlock = !bFirstBlock;
}
else
{
// calculate the number of samples remaining until we ready for a block of audio,
// and wait that amount of time it will take to record.
int remaining = bFirstBlock ? (midPoint - writePos) : (_recording.samples - writePos);
float timeRemaining = (float)remaining / (float)_recordingHZ;
yield return new WaitForSeconds(timeRemaining);
}
}
yield break;
}
private void OnRecognize(SpeechRecognitionEvent result, Dictionary<string, object> customData)
{
if (result != null && result.results.Length > 0)
{
foreach (var res in result.results)
{
foreach (var alt in res.alternatives)
{
string text = string.Format("{0} ({1}, {2:0.00})\n", alt.transcript, res.final ? "Final" : "Interim", alt.confidence);
Log.Debug("ExampleStreaming.OnRecognize()", text);
ResultsField.text = text;
if(res.final == true)
{
GolemControllerObj.GolemActions(alt.transcript);
}
}
if (res.keywords_result != null && res.keywords_result.keyword != null)
{
foreach (var keyword in res.keywords_result.keyword)
{
Log.Debug("ExampleStreaming.OnRecognize()", "keyword: {0}, confidence: {1}, start time: {2}, end time: {3}", keyword.normalized_text, keyword.confidence, keyword.start_time, keyword.end_time);
}
}
if (res.word_alternatives != null)
{
foreach (var wordAlternative in res.word_alternatives)
{
Log.Debug("ExampleStreaming.OnRecognize()", "Word alternatives found. Start time: {0} | EndTime: {1}", wordAlternative.start_time, wordAlternative.end_time);
foreach(var alternative in wordAlternative.alternatives)
Log.Debug("ExampleStreaming.OnRecognize()", "\t word: {0} | confidence: {1}", alternative.word, alternative.confidence);
}
}
}
}
}
private void OnRecognizeSpeaker(SpeakerRecognitionEvent result, Dictionary<string, object> customData)
{
if (result != null)
{
foreach (SpeakerLabelsResult labelResult in result.speaker_labels)
{
Log.Debug("ExampleStreaming.OnRecognize()", string.Format("speaker result: {0} | confidence: {3} | from: {1} | to: {2}", labelResult.speaker, labelResult.from, labelResult.to, labelResult.confidence));
}
}
}

How to Remove multiple markers from map using MapBox SDK

I am using mapbox sdk for offline map, i have added markers like
public void parseStops(String type) {
if (type.equals(activity.getResources().getString(R.string.allStops))) {
alStops = stopsOperations.selectData("walking");
} else {
Log.d("RouteType:", ":" + type);
alStops = stopsOperations.selectDataByType(type);
}
if (alStops.size() > 0) {
for (int i = 0; i < alStops.size(); i++) {
stopsEntity = new StopsEntity();
stopsEntity = alStops.get(i);
title = stopsEntity.getTitle();
lonngt = stopsEntity.getLongitude();
lat = stopsEntity.getLattitude();
routeType = stopsEntity.getType();
stopNumber = stopsEntity.getStopNumber();
Log.d("stopNumber:", ":" + stopNumber);
marker = new Marker(stopsEntity.getTitle(), "", new LatLng(
Double.parseDouble(stopsEntity.getLattitude()),
Double.parseDouble(stopsEntity.getLongitude())));
View view = ((LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.custom_marker_layout, null);
ivPin = (ImageView) view.findViewById(R.id.ivPin);
tvStopNumber = (TextView) view.findViewById(R.id.tvStopNumber);
if (routeType != null) {
if (routeType.equals(activity.getResources().getString(
R.string.walking1))
&& ((alStops.get(i).getStopNumber().equals("79"))
|| (alStops.get(i).getStopNumber()
.equals("98"))
|| (alStops.get(i).getStopNumber()
.equals("99")) || (alStops.get(i)
.getStopNumber().equals("125")))) {
ivPin.setImageResource(R.drawable.walking);
} else if (routeType.equals(activity.getResources()
.getString(R.string.red))) {
ivPin.setImageResource(R.drawable.pin_red);
} else if (routeType.equals(activity.getResources()
.getString(R.string.blue))) {
ivPin.setImageResource(R.drawable.blue_pin);
} else if (routeType.equals(activity.getResources()
.getString(R.string.orange))) {
ivPin.setImageResource(R.drawable.pin_orange);
} else if (routeType.equals(activity.getResources()
.getString(R.string.yellow))) {
ivPin.setImageResource(R.drawable.pin_yellow);
} else if (routeType.equals(activity.getResources()
.getString(R.string.lilac))) {
ivPin.setImageResource(R.drawable.pin_lilac);
} else if (routeType.equals(activity.getResources()
.getString(R.string.interchangee))) {
ivPin.setImageResource(R.drawable.pin_interchange);
}
}
if (stopNumber != null) {
if (stopNumber.length() < 2) {
tvStopNumber.setText("0" + stopNumber.toString());
} else {
tvStopNumber.setText(stopNumber.toString());
}
}
if (routeType != null
&& (alStops.get(i).getTitle().equalsIgnoreCase(activity
.getResources().getString(R.string.start)))
|| (alStops.get(i).getTitle().equalsIgnoreCase(activity
.getResources().getString(R.string.end)))) {
marker.setMarker(new BitmapDrawable(UDF
.createDrawableFromView1(activity, view)));
} else {
marker.setMarker(new BitmapDrawable(UDF
.createDrawableFromView1(activity, view)));
}
mv.addMarker(marker);
if (routeType != null
&& !routeType.equals(activity.getResources().getString(
R.string.walking1))) {
marker = new Marker(stopsEntity.getTitle(), "", new LatLng(
Double.parseDouble(stopsEntity.getLattitude()),
Double.parseDouble(stopsEntity.getLongitude())));
marker.setMarker(activity.getResources().getDrawable(
R.drawable.bus));
mv.addMarker(marker);
}
}
}
}
After that i need to remove these all added markers for some cases.
So, how can i remove all the markers simultaneously.
Can any one help me?
The MapView class has a method called clear:
void clear() Remove all markers from the map's display.
https://www.mapbox.com/mapbox-android-sdk/api/0.7.0/com/mapbox/mapboxsdk/views/MapView.html#clear()
For mapbox-android-sdk:3.0.0, the method is:
mMapView.removeAllAnnotations();
And, the .clear() method is no more.

Settings Non-English language password on android phone?

With Reference to this question on android stack, i have a solution to do which allows android phone to provide support for setting non-english language password.
My phones SRC is based on stock-android which is not allowing me to set password which is non-ascii standards like Hebrew.
Based from AOSP source code that handles the password input for lock screen, ChooseLockPassword.java, inside validatePassword() (line 292), here is a snippet that will show the "illegal character" message (from line 311):
// allow non control Latin-1 characters only
if (c < 32 || c > 127) {
return getString(R.string.lockpassword_illegal_character);
}
I have commented out this part but i don't think so this will work. [Waiting to be Flashed]
There are no such question for this condition, i need help for cracking the possibility for doing this any "Work around" will also do.
So after fighting few days i got a workaround by implementing my method for it.
private String validateHebrewPassword(String password)
{
if (password.length() < mPasswordMinLength) {
return getString(mIsAlphaMode ?
R.string.lockpassword_password_too_short
: R.string.lockpassword_pin_too_short, mPasswordMinLength);
}
if (password.length() > mPasswordMaxLength) {
return getString(mIsAlphaMode ?
R.string.lockpassword_password_too_long
: R.string.lockpassword_pin_too_long, mPasswordMaxLength + 1);
}
for (int i = 0; i < password.length(); i++)
{
char c = password.charAt(i);
System.out.println("Validate Hebrew Password Success "+ " Char "+c+" for password "+password+ " langauage "+locale);
}
return null;
}
And modiying its validatePasswor() caller a bit specific to hebrew like:
private void handleNext() {
final String pin = mPasswordEntry.getText().toString();
if (TextUtils.isEmpty(pin)) {
return;
}
String errorMsg = null;
if (mUiStage == Stage.Introduction)
{
String locale = java.util.Locale.getDefault().getLanguage();
if(locale.equals("iw")) //Specific Hebrew check
{
errorMsg = validateHebrewPassword(pin); //New Method
}
else
{
errorMsg = validatePassword(pin); //AOSP Method
}
if (errorMsg == null)
{
mFirstPin = pin;
mPasswordEntry.setText("");
updateStage(Stage.NeedToConfirm);
}
} else if (mUiStage == Stage.NeedToConfirm) {
if (mFirstPin.equals(pin)) {
final boolean isFallback = getActivity().getIntent().getBooleanExtra(
LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
mLockPatternUtils.clearLock(isFallback);
mLockPatternUtils.saveLockPassword(pin, mRequestedQuality, isFallback);
getActivity().setResult(RESULT_FINISHED);
getActivity().finish();
} else {
CharSequence tmp = mPasswordEntry.getText();
if (tmp != null) {
Selection.setSelection((Spannable) tmp, 0, tmp.length());
}
updateStage(Stage.ConfirmWrong);
}
}
if (errorMsg != null) {
showError(errorMsg, mUiStage);
}
}
private void updateUi() {
String password = mPasswordEntry.getText().toString();
final int length = password.length();
if (mUiStage == Stage.Introduction && length > 0) {
if (length < mPasswordMinLength) {
String msg = getString(mIsAlphaMode ? R.string.lockpassword_password_too_short
: R.string.lockpassword_pin_too_short, mPasswordMinLength);
mHeaderText.setText(msg);
mNextButton.setEnabled(false);
} else
{
String locale = java.util.Locale.getDefault().getLanguage();
String error = null;
if(locale.equals("iw")) //Specific Hebrew check
{
error = validateHebrewPassword(password); //New method
}
else
{
error = validatePassword(password); //AOSP Method
}
if (error != null) {
mHeaderText.setText(error);
mNextButton.setEnabled(false);
} else {
mHeaderText.setText(R.string.lockpassword_press_continue);
mNextButton.setEnabled(true);
}
}
} else {
mHeaderText.setText(mIsAlphaMode ? mUiStage.alphaHint : mUiStage.numericHint);
mNextButton.setEnabled(length > 0);
}
mNextButton.setText(mUiStage.buttonText);
}

How to stop Get data when orientation changes for selecting Checkbox

In my screen i am showing checkboxes with response of using GET when it is getting 0 means setchecked(false) and when it is getting 1 means setchecked(true).
Problem:
Consider when i am selected Multiple checkboxes and changed my
orientation the fragment is getting reloaded and it binding data from
GET method .How to overcome this problem .I am posting my code on
below .
#Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
if(savedInstanceState!=null)
{
cBox_furnishing.setChecked(savedInstanceState.getBoolean("Furnish"));
cBox_washMachine.setChecked(savedInstanceState.getBoolean("washMachine"));
cBox_ac.setChecked(savedInstanceState.getBoolean("ac"));
cBox_microwaveOven.setChecked(savedInstanceState.getBoolean("microwaveOven"));
cBox_ctv.setChecked(savedInstanceState.getBoolean("ctv"));
cBox_refrigerator.setChecked(savedInstanceState.getBoolean("refrigerator"));
cBox_tw.setChecked(savedInstanceState.getBoolean("tw"));
cBox_music.setChecked(savedInstanceState.getBoolean("music"));
cBox_pc.setChecked(savedInstanceState.getBoolean("pc"));
cBox_car.setChecked(savedInstanceState.getBoolean("car"));
}
Fragment_resident_info.leadno = getArguments().getString("LeadNo");
getdata();
}
#Override
public void onSaveInstanceState(Bundle savedInstanceState)
{
b_furnishing_CHECK = cBox_furnishing.isChecked();
b_washMachine_CHECK = cBox_washMachine.isChecked();
b_ac_CHECK = cBox_ac.isChecked();
b_microwaveOven_CHECK = cBox_microwaveOven.isChecked();
b_ctv_CHECK = cBox_ctv.isChecked();
b_refrigerator_CHECK = cBox_refrigerator.isChecked();
b_tw_CHECK = cBox_tw.isChecked();
b_music_CHECK = cBox_music.isChecked();
b_pc_CHECK = cBox_pc.isChecked();
b_car_CHECK = cBox_car.isChecked();
savedInstanceState.putBoolean("Furnish", b_furnishing_CHECK);
savedInstanceState.putBoolean("washMachine", b_washMachine_CHECK);
savedInstanceState.putBoolean("ac", b_ac_CHECK);
savedInstanceState.putBoolean("microwaveOven", b_microwaveOven_CHECK);
savedInstanceState.putBoolean("ctv", b_ctv_CHECK);
savedInstanceState.putBoolean("refrigerator", b_refrigerator_CHECK);
savedInstanceState.putBoolean("tw", b_tw_CHECK);
savedInstanceState.putBoolean("music", b_music_CHECK);
savedInstanceState.putBoolean("pc", b_pc_CHECK);
savedInstanceState.putBoolean("car", b_car_CHECK);
super.onSaveInstanceState(savedInstanceState);
}
private BroadcastReceiver reciever_assetseen = new BroadcastReceiver()
{
#Override
public void onReceive(Context context, Intent intent) {
String response = intent.getStringExtra("httpResponse");
try
{
JSONArray ary = new JSONArray(response);
JSONObject obj = ary.getJSONObject(0);
String st_furnishing = obj.getString("Residence_Furnish");
String st_washingmachine = obj.getString("Washing_Machine");
String st_Ac = obj.getString("AC");
String st_microwaveoven = obj.getString("Microwave_Oven");
String st_ctv = obj.getString("CTV");
String st_refridge = obj.getString("Refrigerator");
String st_tw = obj.getString("TW");
String st_music = obj.getString("Music");
String st_pc = obj.getString("PC");
String st_car = obj.getString("CAR");
if(b_furnishing_CHECK == true)
{
cBox_furnishing.setChecked(true);
}
else if(st_furnishing.equals("0") || st_furnishing.equals("null") )
{
cBox_furnishing.setChecked(false);
}
else
{
cBox_furnishing.setChecked(true);
}
if(b_washMachine_CHECK == true)
{
cBox_washMachine.setChecked(true);
}
else if(st_washingmachine.equals("0") || st_washingmachine.equals("null") )
{
cBox_washMachine.setChecked(false);
}
else
{
cBox_washMachine.setChecked(true);
}
if( b_ac_CHECK == true)
{
cBox_ac.setChecked(true);
}
else if(st_Ac.equals("0")|| st_Ac.equals("null"))
{
cBox_ac.setChecked(false);
}
else
{
cBox_ac.setChecked(true);
}
if( b_microwaveOven_CHECK == true)
{
cBox_microwaveOven.setChecked(true);
}
else if(st_microwaveoven.equals("0") || st_microwaveoven.equals("null") )
{
cBox_microwaveOven.setChecked(false);
}
else
{
cBox_microwaveOven.setChecked(true);
}
if( b_ctv_CHECK == true)
{
cBox_ctv.setChecked(true);
}
else if(st_ctv.equals("0")|| st_ctv.equals("null") )
{
cBox_ctv.setChecked(false);
}
else
{
cBox_ctv.setChecked(true);
}
if( b_refrigerator_CHECK == true)
{
cBox_refrigerator.setChecked(true);
}
else if(st_refridge.equals("0")|| st_refridge.equals("null") )
{
cBox_refrigerator.setChecked(false);
}
else
{
cBox_refrigerator.setChecked(true);
}
if( b_tw_CHECK == true)
{
cBox_tw.setChecked(true);
}
else if(st_tw.equals("0")|| st_tw.equals("null") )
{
cBox_tw.setChecked(false);
}
else
{
cBox_tw.setChecked(true);
}
if( b_music_CHECK == true)
{
cBox_music.setChecked(true);
}
else if(st_music.equals("0")|| st_music.equals("null"))
{
cBox_music.setChecked(false);
}
else
{
cBox_music.setChecked(true);
}
if( b_pc_CHECK == true)
{
cBox_pc.setChecked(true);
}
else if(st_pc.equals("0")|| st_pc.equals("null") )
{
cBox_pc.setChecked(false);
}
else
{
cBox_pc.setChecked(true);
}
if( b_car_CHECK == true)
{
cBox_car.setChecked(true);
}
else if(st_car.equals("0")|| st_car.equals("null"))
{
cBox_car.setChecked(false);
}
else
{
cBox_car.setChecked(true);
}
}
catch(Exception e)
{
}
}
};
if(savedInstanceState!=null)
{
cBox_furnishing.setChecked(savedInstanceState.getBoolean("Furnish"));
cBox_washMachine.setChecked(savedInstanceState.getBoolean("washMachine"));
cBox_ac.setChecked(savedInstanceState.getBoolean("ac"));
cBox_microwaveOven.setChecked(savedInstanceState.getBoolean("microwaveOven"));
cBox_ctv.setChecked(savedInstanceState.getBoolean("ctv"));
cBox_refrigerator.setChecked(savedInstanceState.getBoolean("refrigerator"));
cBox_tw.setChecked(savedInstanceState.getBoolean("tw"));
cBox_music.setChecked(savedInstanceState.getBoolean("music"));
cBox_pc.setChecked(savedInstanceState.getBoolean("pc"));
cBox_car.setChecked(savedInstanceState.getBoolean("car"));
}else{
Fragment_resident_info.leadno = getArguments().getString("LeadNo");
getdata();
}

Categories

Resources