|
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
|
|
|
|
|
|
Thank you,
But I checked the link common navigation pattern in the same page, but I didn't find any code, it is just an information.
Regards,
|
|
|
|
|
Yes, because it is just suggested patterns. You are expected to decide what you wish to implement and write the code yourself.
|
|
|
|
|
I would like to use Tab bar, so if I use deprecated interface, is there any problem?
|
|
|
|
|
aahamdan wrote: so if I use deprecated interface, is there any problem? I would assume it means you can't develop for Android 5 (API 21) or newer. If your target audience is older than that, you should have no problem.
"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
|
|
|
|
|
aahamdan wrote: is there any problem? There is only one way to find out.
|
|
|
|
|
Hello,
Can someone assist me with codes that I manipulates an android phone to take a vehicle number plate picture then extract the texts and maps it to the details of the registered owner.
Thanks in advance.
|
|
|
|
|
There are several libraries available for reading license plates. I used this one in my VanityPlates app. However, who that vehicle is registered to is not public information.
"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
|
|
|
|
|
can I in any way obtain such source codes in android?
|
|
|
|
|
To what exactly?
"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
|
|
|
|
|
I designed app to make order for pizza food restaurant
I show userid,menu id ,address,longtiude,latitude then press on button make order
Error show after I press button and found in async task doin background
It give me fatal exception error
An error occurred while executing doInBackground()
and it show to me two lines have proplem
AddNewOrder.doInBackground(Summary.java:113)
AddNewOrder.doInBackground(Summary.java:77)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.json.JSONObject.getBoolean(java.lang.String)' on a null object reference
package com.pizza_final_project_app.pizza_final_project;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class Summary extends Activity {
SharedPreferences preferences;
private ProgressDialog pDialog;
//JSONParser jsonParser = new JSONParser();
boolean errorFound;
TextView textaddress;
TextView textlongtiude;
TextView textlatitude;
TextView text2;
TextView textuser;
Button btnorder;
private static final String TAG_SUCCESS = "success";
private static final String TAG = Summary.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_summary);
text2=(TextView)findViewById(R.id.textView3);
textaddress=(TextView)findViewById(R.id.textaddress);
textuser=(TextView)findViewById(R.id.textView4);
textlongtiude=(TextView)findViewById(R.id.textlongtiude);
textlatitude=(TextView)findViewById(R.id.textlatitude);
Intent i = getIntent();
String id = i.getStringExtra("Data4");
String address = i.getStringExtra("Data8");
String longtiude = i.getStringExtra("Data9");
String latitude = i.getStringExtra("Data10");
text2.setText(id);
textaddress.setText(address);
textlongtiude.setText(longtiude);
textlatitude.setText(latitude);
preferences= PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
String email=preferences.getString("email","");
textuser.setText(email);
pDialog = new ProgressDialog(this);
pDialog.setCancelable(false);
btnorder=(Button)findViewById(R.id.button2);
btnorder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
addOrder(textuser.getText().toString().trim(), text2.getText().toString().trim(),
textaddress.getText().toString().trim(), textlongtiude.getText().toString().trim(),
textlatitude.getText().toString().trim());
}
});
}
//line 77
class AddNewOrder extends AsyncTask<string, string,="" string=""> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Summary.this);
pDialog.setMessage("Making Order...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
protected String doInBackground(String... args) {
final JSONParser jsonParser = new JSONParser();
// Building Parameters
List<namevaluepair> params = new ArrayList<namevaluepair>();
params.add(new BasicNameValuePair("userID", args[0]));
params.add(new BasicNameValuePair("menuID", args[1]));
params.add(new BasicNameValuePair("address", args[2]));
params.add(new BasicNameValuePair("longitude", args[3]));
params.add(new BasicNameValuePair("latitude", args[4]));
JSONObject jObj = jsonParser.makeHttpRequest(AppConfig.URL_Order,
"POST", params);
try {
//Line 113
boolean error = jObj.getBoolean("error");
if (!error) {
errorFound=false;
} else {
errorFound=true;
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
if (pDialog.isShowing()) {
pDialog.dismiss();
if (!errorFound){
Toast.makeText(getApplicationContext(), "User successfully registered. Try login now!", Toast.LENGTH_LONG).show();
Intent intent = new Intent(
Summary.this,
FinalResult.class);
startActivity(intent);
finish();
}
else{
Toast.makeText(getApplicationContext(), "An Error occoured!", Toast.LENGTH_LONG).show();
}
}
}
}
*/
private void addOrder(final String userID, final String menuID, final String address,
final String longitude, final String latitude) {
new AddNewOrder().execute(userID, menuID, address, longitude, latitude);
}
}
Class AppConfig
package com.pizza_final_project_app.pizza_final_project;
public class AppConfig {
public static String URL_Order = "http://amit-learning.com/myPizza/Api_v2.php?functi...";
json parser
package com.pizza_final_project_app.pizza_final_project;
import android.util.Log;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
// constructor
public JSONParser() {
}
// function get json from url
// by making HTTP POST or GET mehtod
public JSONObject makeHttpRequest(String url, String method,
List<namevaluepair> params) {
// Making HTTP request
try {
// check for request method
if(method == "POST"){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}else if(method == "GET"){
// request method is GET
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
Log.d("data",url);
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
Log.d("json","data is "+json);
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
}
}
|
|
|
|
|
Post only relevant code next time.
The error text plainly states that jObj is null .
"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
|
|
|
|