I am new to Kumulos development.
I want to get selected data from table of kumulos.
Like If user enter username and password i check from table that data exits or not.
But the issue is while checking data inserted in table and not giving me correct output.
While testing api in browser it works fine.
My code for select from table is below.
public void CallApiLogin(){
final String Uname=editUname.getText().toString();
final String pass=editPass.getText().toString();
HashMap<String, String> params = new HashMap<String, String>();
params.put("name", Uname);
params.put("password",pass);
Kumulos.call("user_register", params, new ResponseHandler() {
#Override
public void didCompleteWithResult(Object result) {
// Do updates to UI/data models based on result
ArrayList<LinkedHashMap<String, Object>> objects = (ArrayList<LinkedHashMap<String,Object>>) result;
for (LinkedHashMap<String, Object> item : objects) {
String name = (String) item.get("name");
String password = (String) item.get("password");
if(name.equalsIgnoreCase(Uname) && password.equalsIgnoreCase(pass)){
Intent i=new Intent(Login.this,Home.class);
startActivity(i);
}else{
Toast.makeText(getApplicationContext(),"Please enter valid username and password.",Toast.LENGTH_SHORT).show();
}
}
}
});
}
Please suggest where i am going wrong as requested data inserted in table.
But i want that request data exist or not????
After spending hours, I got solution.
Issue is creating api. In Kumulos you have to create different api.
I was using api "user_register", Now i have create other api call "Select_user".
This api works fine what the result i want.
I hope this question may help some other.
Related
Creating an app on Android studio, have a registration page working which updates the User table on back4app - it also creates a session table with sessionID associated with the account. I'm trying to make it so once the username and password have been confirmed and added the user is brought to a new page and more details are further taken and added to the row in the same User table.
My code for the section looks like
private void addPersonalDetailsToDatabase(String firstname,
String lastname,
String dob,
String addressline1,
String addressline2,
String postcode,
String livealone,
String havecarers) {
ParseObject userList = new ParseObject("User");
userList.put("firstname", firstname);
userList.put("lastname", lastname);
userList.put("dob", dob);
userList.put("addressline1", addressline1);
userList.put("addressline2", addressline2);
userList.put("postcode", postcode);
userList.put("livealone", livealone);
userList.put("havecarers", havecarers);
userList.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Toast.makeText(PersonalDetailsForm.this, "Successful", Toast.LENGTH_SHORT).show();
openPDConfirmed();
} else {
Toast.makeText(getApplicationContext(), e.getMessage().toString(), Toast.LENGTH_SHORT).show();
}
}
});
}
However when I run this code and enter the details it creates a new User table with a brand new row which isn't then accessed by the sessionID.
What I'm trying to do is to add these new columns and their contents to the original user table for the user that has just logged in. Is there any errors in my code or any way that I could add new columns to an already existing row.
Try ParseObject userList = new ParseObject("_User"); or ParseUser userList = new ParseUser();
The application I'm developing is really similar to Instagram.
On Instagram, users can change their usernames anytime. And if you change your username, your posts also show the updated username.
How can I implement this on a firebase database environment?
For example, I have VO below.
#IgnoreExtraProperties
public class Post {
String uid;
String username;
String content;
int likesCount = 0;
Map<String, Boolean> likes = new HashMap<>();
Map<String, Boolean> hashtags = new HashMap<>();
public Post() {
// Default constructor required for calls to DataSnapshot.getValue(Post.class)
}
public Post(String uid, String username, String content) {
this.uid = uid;
this.username = username;
this.content = content;
}
#Exclude
public Map<String, Object> toMap() {
HashMap<String, Object> result = new HashMap<>();
result.put("uid", uid);
result.put("username", username);
result.put("content", content);
result.put("likesCount", likesCount);
result.put("likes", likes);
result.put("hashtags", hashtags);
return result;
}
}
If I include "username" in the Post Object, I can show each post with the usernames synchronously, but it will be difficult to show the latest updated "username" all the time.
If one user's Posts are over 1000, should I update all the posts at the same time when the username is changed?
If I exclude "username" in Post object I can load updated "username" asynchronously each time after any Post is loaded.
Or at the first time just show old username, and check if it is changed everytime when the Post is loaded, and update it asynchronously.
Which is the most efficient and proper way to implement for it?
I'm new in Multiplayer programming. How to set String into hashmap value ? I want to call hashmap properties from RoomListActivity and set it's value on QuizMaintain activity and also I want to set hashmap value from QuizMaintain class to textview. Here's my sample code
RoomListActivity
public void onJoinNewRoomClicked(View view){
progressDialog = ProgressDialog.show(this,"","Please wait...");
progressDialog.setCancelable(true);
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put("timer", "");
properties.put("question", "");
properties.put("answer", "");
properties.put("foulanswer", "");
theClient.createRoom(""+System.currentTimeMillis(), "Yoshua", 2, properties);
}
Then I want to set it's value from QuizMaintain activity
public class QuizMaintain extends Activity implements RoomRequestListener, NotifyListener {
private WarpClient theClient;
private HashMap<String, Object> properties;
private TextView txttimer,txtquestion;
private String roomId = "";
private HashMap<String, User> userMap = new HashMap<String, User>();
String string="5x5#5x4#150:3#500:20#536+59";
String[] questions = string.split("#");
String question1 = questions[0];
String question2 = questions[1];
String question3 = questions[2];
String question4 = questions[3];
String question5 = questions[4];
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz_maintain);
txttimer = (TextView)findViewById(R.id.timer);
txtquestion = (TextView)findViewById(R.id.questionview);
try{
theClient = WarpClient.getInstance();
}catch(Exception e){
e.printStackTrace();
}
theClient.getLiveRoomInfo("143680827");
Intent intent = getIntent();
roomId = intent.getStringExtra("roomId");
init(roomId);
//setquestionview();
}
private void init(String roomId){
if(theClient!=null){
theClient.addRoomRequestListener(this);
theClient.addNotificationListener(this);
theClient.joinRoom(roomId);
}
}
#Override
public void onGetLiveRoomInfoDone(LiveRoomInfoEvent event) {
properties = event.getProperties();
properties.put("question", question1);
}
I want to set hashmap value where is the key are "question". And the value that i want to set are from split string.When I ask their support team if I want to get room properties I should call getLiveRoomInfo method and pass roomID as argument. A bit confused here. Thanks.
But it seems my problem are not solved yet. After call method updateRoomProperties but I got another error here. It's say WarpClient.AddZoneRequestListener(this) return null pointer exception
When you are creating a room you are passing a hashmap. This hashmap is stored as a JSON document inside the room on server. AppWarp calls it Room Properties.
Now to retrieve these properties you have to call getLiveRoomInfo method. This will present you the room properties. Here you are adding/changing some key-value again. But you haven't told the server that you are updating these room properties. Therefore your changes remain local and that too limited to the scope of function.
So, when you call the getLiveRoomInfo method, you won't see the changes as you haven't updated them on server. To update on server, you need to call updateRoomProperties method. In this method you can add or change your hashmap.
Want to create new Record in QuickBlox Custom Table which allready created.
i have Follow the guideline Url and using below method, here i m using my Table name
HashMap<String, Object> fields = new HashMap<String, Object>();
fields.put("User ID",String.valueOf(myID));
fields.put("senderLoginID", ""+mylogin.toString());
fields.put("receiverLoginID", ""+friendLogin.toString());
fields.put("messages", messageString);
fields.put("isRead", false);
QBCustomObject qbCustomObject = new QBCustomObject();
qbCustomObject.setClassName("Movie"); // your Class name
qbCustomObject.setFields(fields);
QBCustomObjects.createObject(qbCustomObject, new QBCallbackImpl() {
#Override
public void onComplete(Result result) {
if (result.isSuccess()) {
QBCustomObjectResult qbCustomObjectResult = (QBCustomObjectResult) result;
QBCustomObject qbCustomObject = qbCustomObjectResult.getCustomObject();
Log.d("New record: ",newCustomObject.toString());
} else {
Log.e("Errors",result.getErrors().toString());
}
}
});
Error getting Like
** '{"errors":{"base":["Forbidden. Need user."]}}'
… Request has been completed with error: [base Forbidden. Need user.]
1st off all, you don't need to use this
fields.put("User ID",String.valueOf(myID));
This field will be filled on the server based on your token information
Next, you have to be logged in in order to create record,
just do the next
http://quickblox.com/developers/SimpleSample-users-android#Sign_In_.26_Social_authorization
I have a problem on arraylist and hashmap
As according to my requirement, I am storing the data into HashMap and after that I have created a List as List>.
HashMap<String,String> hashmap;
static List<HashMap<String,String>> hashmap_string;
And while retrieving the value from database and putting it on HashMap and ArrayList like:
contract_number=c.getString(c1);
Log.i("c1.getString,contract_number", contract_number);
String service_level=c.getString(c2);
hashmap=new HashMap<String, String>();
hashmap.put(contract_number, service_level);
hashmap_string.add(hashmap);
And now I want to retrieve the value as String,String
And when I am applying the code as:
for(int i=0;i<hashmap_string.size();i++)
{
Log.i("arraylist", ""+hashmap_string.get(i));
}
I am getting a single string value in the formet as
{Contract,ServiveValue}
but I want to split this into 2 string values...Also these values are redundant and if am using hashMap then it will not showing me the redundant value.
Please help me on this..
It seems you are missing something. When you execute hashmap_string.get(i), you will get the <HashMap<String,String>. So, This is the right value from code.
What you can do is :
HashMap<String, String> hashMap2 = hashmap_string.get(i);
String value = hashMap2.get("your_key");
Other way, you already have two splited string values. you can get that by using keySet() and values() methods over hashMap2 Object.
HashMap (and Maps in general) are used for multiple one-to-one mappings of keys and values. Are you sure you need that? Looking at your code it appears you're using the map as a "Pair" class. I would skip the list, and put everything in the same map, and then iterate over the pairs in the map:
// using tree map to have entries sorted on the key,
// rather than the key's hash value.
Map<String, String> data = new TreeMap<String, String>();
data.put("c1", "s1");
data.put("c2", "s2");
for (Map.Entry<String, String> entry : data.entrySet()) {
String contract = entry.getKey();
String level = entry.getValue();
Log.i("data", contract + " : " + level");
}
would output (assuming TreeSet):
c1 : s1
c2 : s2
Alternatively, create e.g. a ContractServiceLevel class that holds two strings (the contract number and the service level), and put instances of that class in your list.
EDIT:
public final class ContractServiceLevel {
public final String number;
public final String serviceLevel;
public ContractServiceLevel(String c, String s) {
number = c;
serviceLevel = s;
}
}
List<ContractServiceLevel> contracts = new ArrayList<ContractServiceLevel>();
contracts.add(new ContractServiceLevel("c1", "s1.1"));
contracts.add(new ContractServiceLevel("c1", "s1.2"));
contracts.add(new ContractServiceLevel("c2", "s2.1"));
for (ContractServiceLevel contract : contracts) {
Log.i("data", contract.number + ":" + contract.servicveLevel);
}
would output:
c1 : s1.1
c1 : s1.2
c2 : s2.1
String value = hashmap.get("contract");
u will be getting the value as ServiveValue