|
Learn how to consume REST APIs in Android applications. Then, create a RESTful API to communicate with the cloud. Other frameworks may have other confusion in them and that is one of the reasons why I don't use those frameworks.
Create a simple web applications, Node.js, PHP, ASP.NET, doesn't matter. Allow users to connect using native HTTP protocol, to RESTful APIs, where the communication input and outputs are natively in JSON (no overhead). Then, program the rest of the parts of the application to use that JSON content, and upload the JSON content. For bulk or blob publishing, accept the files and set the enctype to multipart/form-data .
Connecting to the Network | Android Developers[^]
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
here is the logcat
Quote: 07-26 19:48:22.594 2618-2618/com.example.example E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.example, PID: 2618
java.lang.NullPointerException: storage == null
at java.util.Arrays$ArrayList.<init>(Arrays.java:38)
at java.util.Arrays.asList(Arrays.java:155)
at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:128)
at com.example.example.CustomList.<init>(CustomList.java )
at com.example.example.MainActivity1.showJSON(MainActivity1.java:59)
at com.example.example.MainActivity1.access$000(MainActivity1.java:18)
at com.example.example.MainActivity1$1.onResponse(MainActivity1.java:42)
at com.example.example.MainActivity1$1.onResponse(MainActivity1.java:39)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:67)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
MainActivity1.java
package com.example.example;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
public class MainActivity1 extends AppCompatActivity implements View.OnClickListener {
public static final String JSON_URL = "https://drive.google.com/file/d/0B12MlCDj9SefUS1TbW5LVmc0OGM/view?usp=sharing";
private Button buttonGet;
private ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
buttonGet = (Button) findViewById(R.id.buttonGet);
buttonGet.setOnClickListener(this);
listView = (ListView) findViewById(R.id.listView);
}
private void sendRequest(){
StringRequest stringRequest = new StringRequest(JSON_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
showJSON(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MainActivity1.this,error.getMessage(),Toast.LENGTH_LONG).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
private void showJSON(String json){
ParseJSON pj = new ParseJSON(json);
pj.parseJSON();
CustomList cl = new CustomList(this, ParseJSON.ids,ParseJSON.names,ParseJSON.emails);
listView.setAdapter(cl);
}
@Override
public void onClick(View v) {
sendRequest();
}
}
CustomList.java
package com.example.example;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class CustomList extends ArrayAdapter<String> {
private String[] ids;
private String[] names;
private String[] emails;
private Activity context;
public CustomList(Activity context, String[] ids, String[] names, String[] emails) {
super(context, R.layout.list_view_layout, ids);
this.context = context;
this.ids = ids;
this.names = names;
this.emails = emails;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.list_view_layout, null, true);
TextView textViewId = (TextView) listViewItem.findViewById(R.id.textViewId);
TextView textViewName = (TextView) listViewItem.findViewById(R.id.textViewName);
TextView textViewEmail = (TextView) listViewItem.findViewById(R.id.textViewEmail);
textViewId.setText(ids[position]);
textViewName.setText(names[position]);
textViewEmail.setText(emails[position]);
return listViewItem;
}
}
|
|
|
|
|
It is difficult to see exactly which variable is null, but it looks like you are sending a null value from the CustomList constructor, to create the new ArrayAdapter . You should look at your ParseJSON class to see what values it is returning.
|
|
|
|
|
As the exception shows, the problem is a null pointer being referenced with the CustomList class. The line number has been replaced by a blushing emoticon, but as Richard has indicated, the problem may have originated a bit further upstream. Have you stepped through the code using the debugger? What about some strategically placed try/catch blocks?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
how to implement actions example screen lock/unlock,wifi on/off on single tap and double tap on the proximity sensor?
|
|
|
|
|
As with most such questions there is only one answer:
1. Start with some (a lot of) research.
2. Study the documentation and sample code.
3. Write your application.
4. Build and test, correcting any and all bugs.
5. Repeat 4 until everything works.
|
|
|
|
|
please suggest some link for the sample code...
|
|
|
|
|
|
Break your problem down into a handful of smaller problems. Work on them individually. Then you can slowly bring them all together into a unified app. Trying to do ALL of this as a beginner is only going to frustrate you (and whoever you ask for help).
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
how i find coding in xml file
|
|
|
|
|
Sorry, but your question makes no sense. Please edit your post and try explaining exactly what problem you are trying to solve.
|
|
|
|
|
XML files are readable files. The codes in XML files are available in the Android Studio and you can edit them right away.
If I understand correctly, your problem is viewing the XML code instead of the Design tab. For that, look at the bottom[^] of your editor, there are two options:
- Design
- Text
You can use these options to alter the states of drag-and-drop design or text-based editing of the views.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I wanna make Notification in Exact time "Working in background"Android App.
but that open Loop Take all the Battry lifetime !.. So I'm looking for New Way To make it ryt ,is there Better Way ?
public void run() {
BckGround",Toast.LENGTH_LONG).show();
Calendar c = Calendar.getInstance();
Notification notification=new Notification();
notification.sound= Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE+":
int sec = c.get(Calendar.SECOND);
int hours= c.get(Calendar.HOUR_OF_DAY);
int minites=c.get(MINUTE);
int x,y,x2,y2,f,x3,y3,x4,x5,y4,y5;
String Min,hou;
x=19;y=1;
x2=16;y2=1;
x3=18;y3=1;
x4=20;y4=1;
x5=22;y5=1;
f=0;
int d,mo;
d=18;
mo=7;
double Marroftime=720000;
Calendar cn= Calendar.getInstance();
int day=cn.get(Calendar.DAY_OF_WEEK);
int month=cn.get(Calendar.MONTH);
while (true) {
c = Calendar.getInstance();
hours = c.get(Calendar.HOUR_OF_DAY);
minites = c.get(MINUTE);
Min="M is: "+ minites;
hou="H is: "+hours;
if ((hours==x) && (minites==y)&&(f!=minites)){
this.nb.setContentTitle("string");
this.nb.setContentText("Another String");
this.mn.notify(100, nb.build());
f=minites;
try {
Thread.sleep((long) Marroftime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
else if ((hours==x2) && (minites==y2)&&(f!=minites)){
this.nb.setContentTitle("time");
this.nb.setContentText("now is time");
this.mn.notify(100, nb.build());
f=minites;
try {
Thread.sleep((long) Marroftime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
else if ((hours==x3) && (minites==y3)&&(f!=minites)){
this.nb.setContentTitle("now ");
this.nb.setContentText("now is time");
this.mn.notify(100, nb.build());
f=minites;
try {
Thread.sleep((long) Marroftime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
else if ((hours==x4) && (minites==y4)&&(f!=minites)){
this.nb.setContentTitle("String");
this.nb.setContentText("String");
this.mn.notify(100, nb.build());
f=minites;
try {
Thread.sleep((long) Marroftime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
else if ((hours==x5) && (minites==y5)&&(f!=minites)){
this.nb.setContentTitle("String");
this.nb.setContentText("String NEw");
this.mn.notify(100, nb.build());
f=minites;
try {
Thread.sleep((long) Marroftime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
|
|
|
|
|
Member 12509947 wrote: I wanna make Notification in Exact time "Working in background"Android App. What exactly does this mean, and how does it relate to the subject?
As far as the TZ goes, see here. Among other things, you can get the name of your timezone and/or it's offset from UTC.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
POST /WSVistaWebClient/LoyaltyService.asmx HTTP/1.1
Host: api.vista.co.nz
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://vista.co.nz/services/WSVistaWebClient.ServiceContracts/1/CreateMember"
="1.0"="utf-8"
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CreateMemberRequest xmlns="http://vista.co.nz/services/WSVistaWebClient.DataTypes/1/">
<LoyaltyMember>
<MemberId>string</MemberId>
<FirstName>string</FirstName>
<LastName>string</LastName>
<FullName>string</FullName>
<CardNumber>string</CardNumber>
<MobilePhone>string</MobilePhone>
<HomePhone>string</HomePhone>
<Email>string</Email>
<ClubID>string</ClubID>
</LoyaltyMember>
|
|
|
|
|
I am confused.. it looks like a server side question.. What is it doing here?
Anyhow, I would go ahead, assume it's a mistake and give you a server side answer.
There are 2 answers which comes to my mind to that server side question:
- You should write a nice C# service class, here is how to get started with Web Services with ASP.NET
- You can always, if you so choose, pare the XML yourself with the like of XmlElement Class (System.Xml)[^]
|
|
|
|
|
I want to change audio tempo using programming code below Android API 5.0.
Help me!
|
|
|
|
|
|
Thank you for your answer!
Do you have sample code?
Please help me.
|
|
|
|
|
I have to create an app to play an swf/flash file.
But setPluginState method in webview was deprecated in API level 18.
|
|
|
|
|
|
I used "setPluginState(WebSettings.PluginState.ON)" already.
But after running, app display "Can't load plugin" message in WebView.
is there demo code? Help me!!!
|
|
|
|
|
Quote from the documentation: Plugins will not be supported in future, and should not be used .
|
|
|
|
|
Hi Experts,
I am a new to the android, and I am trying to work on Tab Action bar, but I find the below interface was deprecated , so what is the replacement, and what happen if I use deprecated interface?
ActionBar.TabListener
public static interface ActionBar.TabListener
android.support.v7.app.ActionBar.TabListener
|
|
|
|