Open/Close SQL Database on the same thread - android

I'm developing a recipe book and I'm implementing this method to insert my Recipe in the Database. In the for cycle I get the ingredient's name and quantity from multiples EditText, saving each of them in an Ingredient.class instance (newIngredient). Then I insert the instance into the DB and add it to an ArrayList. The followings "if conditions" are for the title, time and other Recipe's attributes. Finally, I also insert Recipe and Tag instances in the relatives DB's tables and I close DB.
public void saveRecipe() {
dbHelper = new DatabaseHelper(context);
// creating new recipe from user input
Ingredient newIngredient;
String title, childIngredient, instruction, tag;
int target, time, childQuantity, calories;
int countIngredients = parentIngredientLayout.getChildCount();
int countTags = chipGroup.getChildCount();
ArrayList<Ingredient> ingredients = null;
ArrayList<Tag> tags = null;
View childViewIng = null;
EditText childTextViewI = null;
EditText childTextViewQ = null;
// ingredients fields settings
for (int d=0; d<countIngredients; d++) {
childViewIng = parentIngredientLayout.getChildAt(d);
childTextViewI = childViewIng.findViewById(R.id.ingredientsField);
childTextViewQ = childViewIng.findViewById(R.id.quantityField);
childIngredient = childTextViewI.getText().toString();
childQuantity = Integer.parseInt(childTextViewQ.getText().toString());
newIngredient = new Ingredient(childIngredient, childQuantity);
dbHelper.insertIngredient(newIngredient);
ingredients.add(newIngredient);
}
//recipe fields settings
if (photoPath1 == null)
photoPath1 = "";
if (photoPath2 == null)
photoPath2 = "";
if (photoPath3 == null)
photoPath3 = "";
if (titleText.getText().toString().isEmpty()) {
title = "";
} else {
title = titleText.getText().toString();
}
if (targetNumber.getText().toString().isEmpty()) {
target = 0;
} else {
target = Integer.parseInt(targetNumber.getText().toString());
}
if (timeNumber.getText().toString().isEmpty()) {
time = 0;
} else {
time = Integer.parseInt(timeNumber.getText().toString());
}
if (instructionText.getText().toString().isEmpty()) {
instruction = "";
} else {
instruction = instructionText.getText().toString();
}
if (caloriesNumber.getText().toString().isEmpty()) {
calories = 0;
} else {
calories = Integer.parseInt(caloriesNumber.getText().toString());
}
if (tagName.getText().toString().isEmpty()) {
tag = "";
} else {
tag = tagName.getText().toString();
}
Recipe newRecipe = new Recipe(title, photoPath1, photoPath2, photoPath3, instruction, target, time, calories, ingredients);
Tag newTag = new Tag(tag);
dbHelper.insertRecipe(newRecipe);
dbHelper.insertTag(newTag);
dbHelper.close(); }
I found out by debugging that in this case is inserted only the first ingredient. I tried to move the FOR until the end of code, but in that case, are inserted both recipe and tag and always only the first ingredient. I think the problem is relative to the opening/closing of the DB. Can somebody help me?
Ingredient constructor:
public Ingredient(String ingredient_name, int quantity) {
this.ingredient_name = ingredient_name;
this.quantity = quantity;
}
dbHelper.insertIngredient(newIngredient) method:
public boolean insertIngredient(Ingredient ingredient) {
db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(INGREDIENT_NAME, ingredient.getIngredient_name());
contentValues.put(QUANTITY, ingredient.getQuantity());
contentValues.put(KEY_CREATED_AT, time.getTime().toString());
long result = db.insert(TBL_INGREDIENTS, null, contentValues);
//db.close();
Log.e(TAG, "Ingredient inserted!");
if (result == -1) {
return false;
} else {
return true;
}
}

Ok, thanks to your comment we got the problem :)
You are calling .add(newIngredient) on a list that you initialized with ArrayList<Ingredient> ingredients = null;
Change it to
ArrayList<Ingredient> ingredients = new ArrayList<Ingredient>();
and it will work :)
Good luck!

Related

Room Data-base how to implement item that needs columns from 2 entities

I've created database with Room with MVVM, and I'm facing a problem I hope you could help me solve this.
I have a database containing 3 entities Player, Group and Standings, where Standings is the relationship between Player and Group.
The things is that I want to present standings, but Standings only contains the IDs of Group and Player, and I want it to also show the name of the player which is in Player, and I'm using LiveData, adapters and ViewModels, so when I return the list of LiveData<List<Standings>> to observe, it doesn't contain the name of the player.
Does someone know how I can pass the name as well?
The only solution that I could think of is to create new class that has a Standing and the name(String) as the instances and then return it to observe.
But it doesn't feel natural so I thought I could find here a better, more elegant solution.
groupStandingsViewModel = ViewModelProviders.of(this, new GroupStandingsViewModelFactory(this.getApplication(), 0)).get(GroupStandingsViewModel.class);
groupStandingsViewModel.getAllStandings().observe(this, new Observer<List<Standings>>() {
#Override
public void onChanged(List<Standings> standings) {
adapter.setStanding(standings);
}
});
I'm expecting to be able to have both the standings and the names as given in the onChanged function of the observe.
The only solution that I could think of is to create new class that
has a Standing and the name(String) as the instances and then return
it to observe.
But it doesn't feel natural so I thought I could find here a better,
more elegant solution.
It may sound unnatural but you will need some new code, so what else? (P.S. that's rhetorical).
I'd suggest a new class is the way to but something like:-
public class PlayerGroupStanding {
#Embedded
Standings standing;
String playerName;
long playerId;
String groupName;
long groupId;
public PlayerGroupStanding() {
}
public Standings getStanding() {
return standing;
}
public void setStanding(Standings standing) {
this.standing = standing;
}
public long getPlayerId() {
return playerId;
}
public void setPlayerId(long playerId) {
this.playerId = playerId;
}
public String getPlayerName() {
return playerName;
}
public void setPlayerName(String playerName) {
this.playerName = playerName;
}
public long getGroupId() {
return groupId;
}
public void setGroupId(long groupId) {
this.groupId = groupId;
}
public String getGroupName() {
return groupName;
}
public void setGroupname(String groupname) {
this.groupName = groupname;
}
}
This could be used in conjunction with a Dao Query along the lines of :-
#Query("SELECT * FROM standings JOIN player ON mapToPlayer = playerId JOIN `group` ON mapToGroup = groupId")
List<PlayerGroupStanding> getAllStandingsWithPlayerAndGroupDetails();
Note the above makes many assumptions as to names, although the given names should be self-explantory.
Note that the names of the variables e.g. playerName should match the column name as returned from the query.
Additional
Re comment
what object does the SELECT returns in a query. I understand that if I use a SELECT * then the object will be of the class that is in the FROM. but when I returns columns, what will be the object that I need to mention in the LiveData>? Where can if find information about it? Thank you very much in advance:D
The SELECT actually returns a Cursor, it's the annotation that then writes the code that extracts the columns as per the definition of the method mapping the columns according to the class's member names to return the object, if additional columns exist they are ignored. The FROM clause doesn't determine the resultant object returned the method after the #Query does according to the type returned from that method.
The actual code can be found after building (Ctrl + F9) in the generated code of the project e.g.
So for the example above then the respective method that is generated in the Dao's code (i.e. Dao suffixd with _impl) is :-
#Override
public List<PlayerGroupStandings> getAllPlayerGroupStandings() {
final String _sql = "SELECT * FROM standings JOIN player ON mapToPlayer = playerId JOIN `group` ON mapToGroup = groupId";
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
__db.assertNotSuspendingTransaction();
final Cursor _cursor = DBUtil.query(__db, _statement, true, null);
try {
final int _cursorIndexOfMapToPlayer = CursorUtil.getColumnIndexOrThrow(_cursor, "mapToPlayer");
final int _cursorIndexOfMapToGroup = CursorUtil.getColumnIndexOrThrow(_cursor, "mapToGroup");
final LongSparseArray<ArrayList<Player>> _collectionPlayers = new LongSparseArray<ArrayList<Player>>();
final LongSparseArray<ArrayList<Group>> _collectionGroup = new LongSparseArray<ArrayList<Group>>();
while (_cursor.moveToNext()) {
if (!_cursor.isNull(_cursorIndexOfMapToPlayer)) {
final long _tmpKey = _cursor.getLong(_cursorIndexOfMapToPlayer);
ArrayList<Player> _tmpPlayersCollection = _collectionPlayers.get(_tmpKey);
if (_tmpPlayersCollection == null) {
_tmpPlayersCollection = new ArrayList<Player>();
_collectionPlayers.put(_tmpKey, _tmpPlayersCollection);
}
}
if (!_cursor.isNull(_cursorIndexOfMapToGroup)) {
final long _tmpKey_1 = _cursor.getLong(_cursorIndexOfMapToGroup);
ArrayList<Group> _tmpGroupCollection = _collectionGroup.get(_tmpKey_1);
if (_tmpGroupCollection == null) {
_tmpGroupCollection = new ArrayList<Group>();
_collectionGroup.put(_tmpKey_1, _tmpGroupCollection);
}
}
}
_cursor.moveToPosition(-1);
__fetchRelationshipplayerAsarmAndroidroommigrationsPlayer(_collectionPlayers);
__fetchRelationshipgroupAsarmAndroidroommigrationsGroup(_collectionGroup);
final List<PlayerGroupStandings> _result = new ArrayList<PlayerGroupStandings>(_cursor.getCount());
while(_cursor.moveToNext()) {
final PlayerGroupStandings _item;
final Standings _tmpStandings;
if (! (_cursor.isNull(_cursorIndexOfMapToPlayer) && _cursor.isNull(_cursorIndexOfMapToGroup))) {
_tmpStandings = new Standings();
final Long _tmpMapToPlayer;
_tmpMapToPlayer = _cursor.getLong(_cursorIndexOfMapToPlayer);
_tmpStandings.setMapToPlayer(_tmpMapToPlayer);
final Long _tmpMapToGroup;
_tmpMapToGroup = _cursor.getLong(_cursorIndexOfMapToGroup);
_tmpStandings.setMapToGroup(_tmpMapToGroup);
} else {
_tmpStandings = null;
}
ArrayList<Player> _tmpPlayersCollection_1 = null;
if (!_cursor.isNull(_cursorIndexOfMapToPlayer)) {
final long _tmpKey_2 = _cursor.getLong(_cursorIndexOfMapToPlayer);
_tmpPlayersCollection_1 = _collectionPlayers.get(_tmpKey_2);
}
if (_tmpPlayersCollection_1 == null) {
_tmpPlayersCollection_1 = new ArrayList<Player>();
}
ArrayList<Group> _tmpGroupCollection_1 = null;
if (!_cursor.isNull(_cursorIndexOfMapToGroup)) {
final long _tmpKey_3 = _cursor.getLong(_cursorIndexOfMapToGroup);
_tmpGroupCollection_1 = _collectionGroup.get(_tmpKey_3);
}
if (_tmpGroupCollection_1 == null) {
_tmpGroupCollection_1 = new ArrayList<Group>();
}
_item = new PlayerGroupStandings();
_item.standings = _tmpStandings;
_item.players = _tmpPlayersCollection_1;
_item.group = _tmpGroupCollection_1;
_result.add(_item);
}
return _result;
} finally {
_cursor.close();
_statement.release();
}
}

How do i fix this error, System.NotSupportedException: Could not activate JNI Handle 0x7fec3e5620

I have tried searching for the error but i can't seem to link the results i find to my application.
Here is the error i get whenever i run my program.
Unhandled Exception:
System.NotSupportedException: Could not activate JNI Handle
0x7fec3e5620 (key_handle 0xe1ccda9) of Java
type 'md5ca0dbb1ec41706184e899fc3d5b0057e/MainActivity'
as managed type 'PowerCellShipping3.MainActivity'. occurred
Here is my c# code. I am unsure what is actually causing the error as i have never come across this error(obviously.)
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
scan = FindViewById<Button>(Resource.Id.btnScan);
lbviewScan = FindViewById<ListView>(Resource.Id.lvbScanned);
lbviewReject = FindViewById<ListView>(Resource.Id.lbRejected);
tvscanned = FindViewById<TextView>(Resource.Id.textView4);
tvreject = FindViewById<TextView>(Resource.Id.textView5);
etLot = FindViewById<EditText>(Resource.Id.etLotNumber);
scan.Click += delegate {
//Call Your Method When User Clicks The Button
btnClick();
};
}
/**************************************************************************************************************************************************************/
public class ToDoTasks
{
[PrimaryKey, AutoIncrement, Column("#Lot_Number")]
public int Id { get; set; }
[MaxLength(100)]
public string Task { get; set; }
}
public List<string> GetData()
{
var db = new SQLiteConnection("Data Source = obdbnsql3; Persist Security Info=True;User ID = sa" + "Password=P0w3r1T");
List<string> data = new List<string>();
foreach (var item in db.Table<ToDoTasks>())
{
var objectItem = item.Task.ToString();
data.Add(objectItem);
}
return data;
}
/***************************************************************************************************************************************************************/
public void btnClick()
{
sql1 = "update [Otto_Internal_Apps].[dbo].[Shipping_Detail] set [Box_Scanned] = 1, [Shipment_Scan_Date] = GETDATE(), [Box_Rejected] = 0 " +
"where [Lot_No] = #Lot_Number and ([Box_Rejected] != 1 or [Box_Rejected] is null)";
SQLiteCommand sqlCommand = new SQLiteCommand(connection);
sqlCommand.CommandText.Replace(sql1,sql1);
string attempt = sql1;
int iCount = Convert.ToInt32(attempt);
sqlCommand.CommandText.Remove(iCount,iCount);
/********************************************************************************************************************************/
string attempt2 = "#Lot_Number";
int iCount2 = Convert.ToInt32(attempt2);
//sqlCommand.Parameters.AddWithValue("#Lot_number", etLot.Text);
sqlCommand.CommandText.Insert(iCount2, etLot.Text);
/********************************************************************************************************************************/
try
{ // Execute the query and return the rows affected
sql2 = "select top 1 * from [Otto_Internal_Apps].[dbo].[Shipping_Detail] where [Lot_No] = #Lot_Number and [Box_Rejected] = 1";
int iRowsAffected = sqlCommand.ExecuteNonQuery();
// if the rows affected is zero then the lot no. does not exist and must be inserted as a rejected scan
if (iRowsAffected == 0)
{
sqlCommand.CommandText = sql2;
sql3 = "INSERT INTO [Otto_Internal_Apps].[dbo].[Shipping_Detail] ([Lot_No],[Box_Rejected]) VALUES(#Lot_Number, 1) ";
//lbviewScan.Load(sqlCommand.ExecuteQuery);
var items = GetData();
var listView = FindViewById<ListView>(Resource.Id.lvbScanned);
listView.Adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, items);
if (lbviewScan.Count == 0)
{
sqlCommand.CommandText = sql3;
string attempt3 = sql3;
int iCount3 = Convert.ToInt32(attempt3);
sqlCommand.CommandText.Remove(iCount3, iCount3);
string attempt4 = "#Lot_Number";
int iCount4 = Convert.ToInt32(attempt4);
sqlCommand.CommandText.Insert(iCount4, etLot.Text);
sqlCommand.ExecuteNonQuery();
}
//int iItemFound = lbviewReject.Items.IndexOf(etLot.Text);
int iItemFound = itemList.IndexOf(etLot.Text);
if (iItemFound == -1)
{
//lbviewReject.Items.Add(etLot.Text);
itemList.Add(etLot.Text);
}
}
else
{
//int iItemFound = lbviewScan.Items.IndexOf(etLot.Text);
int iItemFound = itemList.IndexOf(etLot.Text);
if (iItemFound == -1)
{
//lbviewScan.Items.Add(etLot.Text);
itemList.Add(etLot.Text);
}
Console.Beep(800, 200);
}
}
catch (SQLException sqle)
{
Toast.MakeText(ApplicationContext, sqle.Message, ToastLength.Long).Show();
Console.Beep(2000, 1600);
return;
}
The other posts that I saw on the Xamarin site seemed to be similar errors but like i said before, I still can't find a solution.
I think that the error could be caused due to one of the listboxes but i am unsure about that.
Any help would be greatly appreciated. Thanks

Couchbase - query is not updated

I made a filter and filtering the values from the couch-base. Only first time i am able to getting the right filter values, after that it is returing the previous filter values every time. So i have to clear the cache every time. Please help.
Here is my query code.
public Query getFilterQuery(final String titles, final String sender,
final String sysName, final String prosName, final String fromDate,
final String toDate) {
final SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
com.couchbase.lite.View view = database.getView(FILTER_VIEW);
if (view.getMap() == null) {
Mapper mapper = new Mapper() {
public void map(Map<String, Object> document, Emitter emitter) {
String type = (String) document.get(AppConstants.KEY_DOC_TYPE);
if (AppConstants.DOC_TYPE_MESSAGE.equals(type)) {
String message_type = (String) document.get(AppConstants.MESSAGE_TYPE);
Log.d("message_type", message_type);
if (message_type.equals("task")) {
String msgDetails = (String) document.get(AppConstants.MESSAGE_BODY);
try {
JSONObject msgObj = new JSONObject(msgDetails);
DocumentReader documentReader = mApplication
.getDocumentReader(message_type);
documentReader.setJsonObject(msgObj);
String title = (String) documentReader.getValue("task.title");
JSONArray infoArray = (JSONArray) documentReader.getValue("task.info");
String taskDate = null;
String senderName = null;
String processName = null;
for (int i = 0; i < infoArray.length(); i++) {
JSONObject jObject = infoArray
.getJSONObject(i);
String field_label = jObject
.getString(AppConstants.LABEL);
if (field_label.equals(TASK_DATE)) {
taskDate = jObject
.getString(AppConstants.FIELD_VALUE);
Log.d("taskDate", taskDate);
}
if (field_label.equals(SENDER)) {
senderName = jObject
.getString(AppConstants.FIELD_VALUE);
}
if (field_label.equals(PROCESS_NAME)) {
processName = jObject
.getString(AppConstants.FIELD_VALUE);
}
}
Date dateFrom = null;
Date dateTo = null;
try {
date = dateFormat.parse(taskDate);
Log.d("taskDate", taskDate);
if (toDate != null && fromDate != null) {
dateTo = dateFormat.parse(toDate);
dateFrom = dateFormat.parse(fromDate);
}
} catch (ParseException e) {
e.printStackTrace();
}
/*if (titles != null && titles.contains(title)) {
emitter.emit(document.get(AppConstants.MESSAGE_ID),document);
}*/
if (senderName != null && senderName.contains(sender)) {
emitter.emit(document.get(AppConstants.MESSAGE_ID),document);
}
/*if (processName != null && processName.contains(prosName)) {
emitter.emit(document.get(AppConstants.MESSAGE_ID),document);
}*/
/*if (date.before(dateTo) && date.after(dateFrom)) {
emitter.emit(document.get(AppConstants.MESSAGE_ID),document);
}*/
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
};
view.setMap(mapper, "1");
}
Query query = view.createQuery();
return query;
}
}
A Query in Couchbase-lite is split into 2 parts.
Setting up the view (basically - the index)
Running the query against the view.
You should create you view only once (your mapper) and run queries against it with a search term under startkey and endkey.
You can also do a compound index, which is basically a string compound from several keys and search by it.
If you set the map everytime you run the query-the query will not be updated, as it look at you version argument and it's always set to a string "1".
if you will change it you will get a new index for you query - but it should be used only in dev when you change your view.
Roi.

Programmatically set R.ID

I downloaded a class from Catch The Cows, it is akin to a Google Map object or at least that is what I am using it for.
It parses an XML file which lists the areas of the screen that should be touchable, and then creates them with this method.
This is here for context, I have commented out some parts of code, and added my own to try and resolve my issue
private Area addShape( String shape, String name, String coords, String id) {
Log.v("IDS:", "id was "+id);
Area a = null;
String rid = id.replace("#+id/", "");
Log.v("IDS:", "rid was "+rid);
// Generate a new ID for the area.
int _id = 1;
View vi = findViewById(_id);
while (vi!=null) {
_id++;
vi = findViewById(_id);
}
//View.generateViewId(); //=0;
Log.v("IDS:", "After conversion final time "+_id);
/*
try {
Class<R.id> res = R.id.class;
Field field = res.getField(rid); // eg. rid = area10
_id = field.getInt(null);
Log.v("IDS:", "After conversion "+_id);
}
catch (Exception e) {
_id = 0;
Log.e("Exception ",e.getMessage());
} finally {
Log.v("IDS:", "After conversion final time "+_id);
}
*/
if (_id != 0) {
if (shape.equalsIgnoreCase("rect")) {
String[] v = coords.split(",");
if (v.length == 4) {
a = new RectArea(_id, name, Float.parseFloat(v[0]),
Float.parseFloat(v[1]),
Float.parseFloat(v[2]),
Float.parseFloat(v[3]));
}
}
if (shape.equalsIgnoreCase("circle")) {
String[] v = coords.split(",");
if (v.length == 3) {
a = new CircleArea(_id,name, Float.parseFloat(v[0]),
Float.parseFloat(v[1]),
Float.parseFloat(v[2])
);
}
}
if (shape.equalsIgnoreCase("poly")) {
a = new PolyArea(_id,name, coords);
}
if (a != null) {
addArea(a);
}
} else {
Log.v("Loading ID: ","_id was 0");
}
return a;
}
Unfortunately nothing was rendering on the screen, and this was because _id = 0. This should be changed with this bit of code:
try {
Class<R.id> res = R.id.class;
Field field = res.getField(rid); // eg. rid = area10
_id = field.getInt(null);
}
How ever I am not sure what it does to try and debug it, can anyone explain what this snippet is doing?
R is a Read-Only class. It is generate at compile time and You should not use reflection to modify its field. Also you should avoid reflection to access the fields values. You should use the official API.
The comment at the first row of the class is
/* AUTO-GENERATED FILE. DO NOT MODIFY. */

Updating values to Hash-table?

I have some problem in updating the values to hash-table,here is my problem i will explain it clearly.
1.I have getting the response from server,i am adding the values to layout,by using layout Layout-Inflater.
2.in our application we have streaming request.when the streaming request is turned on the values need to be updated regularly.
storing values in hash-tables
Hashtable<String, View> indicesHashtable = new Hashtable<String, View>();
For(Step 1)code i have written belowthe code.
private void addIndices(LinearLayout parent, final String key,final String value) {
LayoutInflater factory = LayoutInflater.from(mContext);
final View row = factory.inflate(R.layout.indices_values, null);
final TextView keyTextView = (TextView) row.findViewById(R.id.txtCompany);
final TextView valueTextView = (TextView) row.findViewById(R.id.txtIndex);
final Button iconImageView = (Button) row.findViewById(R.id.btnIcon);
row.setBackgroundResource(android.R.drawable.list_selector_background);
if (value.length() > 0) {
keyTextView.setText(Html.fromHtml("<b>"+indices.get(key)+"</b>"));
valueTextView.setText(Html.fromHtml(value));
if(quoteArrowIconId != -1)
iconImageView.setBackgroundResource(quoteArrowIconId);
else
iconImageView.setBackgroundDrawable(null);
}else{
keyTextView.setText(Html.fromHtml(key));
}
indicesHashtable.put(key, row);
parent.addView(row);
}
For(Step 2)i need help from you guys.
i have written code..that i have shown below.
private void handleResponseOfResponses(ResponseParser response) {
Hashtable responses = (Hashtable) response.getValue(Response_890.RESPONSES);
String[] symbols = new String[responses.size()];
int index = 0;
indicesHashtable.clear();
for(int i =indicesSymbols.length-1; i >= 0; i--){
Enumeration e = responses.keys();
while (e.hasMoreElements()) {
ResponseParser subResponse = (ResponseParser) responses.get(e.nextElement());
if (subResponse.getResponseCode() == ResponseCodes.QUOTES_RESPONSE) {
String[] quoteProperties = (String[]) subResponse.getValue(Response_312.QUOTES_KEY);
if(quoteProperties[0].equalsIgnoreCase(indicesSymbols[i])){
// symbolTable.put(quoteProperties[0].toUpperCase(), index);
symbols[index++] = quoteProperties[0];
String value = quoteValue(quoteProperties);
For displaying the values coming for response i have added (AddIndices)method
addIndices(linear_Indices, quoteProperties[0], value);
}
}
}
}
autoscroll();
indicesStreamerClient = new StreamerClient(indicesSymbols){
#Override
public void onStreamDataReceived(QuoteData quoteData) {
System.out.println("onStreamDataReceived () -> "+quoteData.getSymbol());
HERE I NEED TO ADDED ANOTHER METHOD FOR UPDATING THE VALUES..HOW I CAN WRITE THE CODE.
};
};
Streamer.getInstance(mContext).registerStramerClient(indicesStreamerClient);
}
Guys i am fresher as well as new to andriod.
Thanks in advance!!!!!!

Categories

Resources