Hello,
I wanted to know what is the difference between Context.startService(intent) and startService(intent) and does it matter which one is used?
Thank you
Since most widgets have a standard method of setting a listener, setOnXXXListener(), just wondering why there is no setDateChangedListener() method for DatePicker?
I know init(int, int, int, OnDateChangedListener) can be used for the same purpose, but surely there must be some reason why Google decided not to use the standard method here. I went through the API docs and couldn't find the reason.
Would one of the gurus here know the answer to this?
Hello -
It's me again.. I am not trying to initiate a gallery intent, but I only want it to grab photos in a specific gallery.. From a different post, I received this code:
Intent intent = new Intent();
intent.setType("file:///sdcard/Pictures/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent,1);
But it's not working.. Is this possible?
Hey all!
Is there a way to simulate opening/closing the 'hardware' keyboard in the emulator?
I have to test some changes that I capture using getResources().getConfiguration().keyboardHidden and this would help a fair lot :)
Thank you in advance!
Hi,
I hope the title says it all: I've got Activity A which fires up the Camera intent via:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, REQUEST_CAMERA);
After the picture is taken I can easily grab the picture in:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
But I'd like to receive the result in Activity B in which the image can be edited.
Right now I'm receiving the result in Activity A and pass it over to Activity B which results in showing the GUI of Activity A for a short while:
Intent i = new Intent().setAction("DisplayJPEG");
i.setClass(this, EditImageActivity.class);
i.putExtra("IMAGE_URI", uri);
startActivityForResult(i, REQUEST_EDIT_IMAGE);
Of course, I will need the result from Activity B in Activity A after the image has been edited. But that should work with:
setResult(resultCode, data);
So there has to be a way to do what I need. Please point me into the right direction.
Thanks in advance,
steff
I have a service that regularly queries a web server for new messages. The service stores the new messages in an arrayList. These messages are implemented using a custom class, storing all kinds of metadata (strings and longs).
An activity then connects to this service to retrieve those messages and display them to the user.
I have an .aidl file that describes the interface that the service exposes.
package com.example.package;
interface MyInterface {
List<Message> getMessages();
}
The Message class extends the Parcelable class which should allow for the IPC transfer.
The problem is this: Eclipse gives me an error saying that the type of List<Message> is unknown. Any imports are marked as invalid.
Ideas? Thanks
How do I display an image of arbitrary size without OOMing or downscaling the image.
I dont want to downscale due to zooming and dragging of the picture?
If it isnt possible to display an image of arbitrary size, how do I determine the maximum possible size of the image to display, without causing a OOM?
I've searched for 3 days now but didn't find a solution or similar problem/question anywhere else. Here is the deal:
Trigger in 1 hour - works correct
Trigger in 2 hours - Goes of in 1:23
Trigger in 1 day - Goes of in ~11:00
So why is the AlarmManager so unpredictable and always too soon? Or what am I doing wrong? And is there another way so that it could work correctly?
This is the way I register my PendingIntent in the AlarmManager (stripped down):
AlarmManager alarmManager = (AlarmManager)parent.getSystemService(ALARM_SERVICE);
Intent myIntent = new Intent(parent, UpdateKlasRoostersService.class);
PendingIntent pendingIntent = PendingIntent.getService(parent, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//Set startdate of PendingIntent so it triggers in 10 minutes
Calendar start = Calendar.getInstance();
start.setTimeInMillis(SystemClock.elapsedRealtime());
start.add(Calendar.MINUTE, 10);
//Set interval of PendingIntent so it triggers every day
Integer interval = 1*24*60*60*1000;
//Cancel any similar instances of this PendingIntent if already scheduled
alarmManager.cancel(pendingIntent);
//Schedule PendingIntent
alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, start.getTimeInMillis(), interval, pendingIntent);
//Old way I used to schedule a PendingIntent, didn't seem to work either
//alarmManager.set(AlarmManager.RTC_WAKEUP, start.getTimeInMillis(), pendingIntent);
It would be awesome if anyone has a solution. Thanks for any help!
Update:
2 hours ago it worked to trigger it with an interval of 2 hours, but after that it triggered after 1:20 hours. It's getting really weird. I'll track the triggers down with a logfile and post it here tomorrow.
Update:
The PendingIntent is scheduled to run every 3 hours. From the log's second line it seems like an old scheduled PendingIntent is still running:
[2012-5-3 2:15:42 519] Updating Klasroosters
[2012-5-3 4:15:15 562] Updating Klasroosters
[2012-5-3 5:15:42 749] Updating Klasroosters
[2012-5-3 8:15:42 754] Updating Klasroosters
[2012-5-3 11:15:42 522] Updating Klasroosters
But, I'm sure I cancelled the scheduled PendingIntent's before I schedule a new one. And every PendingIntent isn't recreated in the same way, so it should be exactly the same. If not , this threads question isn't relevant anymore.
I'm trying to display a progressDialog while getting an image from a url to a imageview.
When trying to show the progressDialog the parent activity has leaked window...
Strange thing is that I have two fragments in the this activity, in the first fragment this exact same way of calling the progressdialog works but when the fragment is replaced and i try to make it again it crashes.
This is the asynctask I'm using inside the second fragment with the crash:
class SkinPreviewImage extends AsyncTask<Void, Void, Void> {
private ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("Loading preview...");
if(progressDialog != null) progressDialog.show();
progressDialog.setOnCancelListener(new OnCancelListener() {
public void onCancel(DialogInterface arg0) {
SkinPreviewImage.this.cancel(true);
}
});
}
@Override
protected Void doInBackground(Void... params) {
try {
URL newurl = new URL(url);
Bitmap mIcon_val = BitmapFactory.decodeStream(newurl.openConnection().getInputStream());
skinPreview.setImageBitmap(mIcon_val);
} catch (IOException e) {
Log.e("SkinStoreDetail", e.getMessage());
}
return null;
}
@Override
protected void onPostExecute(Void v) {
if(progressDialog != null) progressDialog.dismiss();
}
}
I've seen a few similar questions but the one closest to solve my problem used a groupactivity for the parent which I'm not using.
Any suggestions?
I would like to have a checkbox preference that takes the user to a new (sub)preference screen if the user presses on the actual text (and not on the checkbox to the right).
Just as the control under Settings - Wireless - Mobile Network Settings - Access Point Names.
I've follow the code for parsing the value with JSON from here, but I get the problem in my return statement. I want to put the parsing result into my return statement. How to do that?
Here is my code:
public String MASUK(String user, String password)
{
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("ccduser");
pi.setValue(user);
pi.setType(String.class);
request.addProperty(pi);
PropertyInfo pi2 = new PropertyInfo();
pi2.setName("password");
pi2.setValue(password);
pi2.setType(String.class);
request.addProperty(pi2);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_ACTION, envelope);
SoapObject resultSOAP = (SoapObject) envelope.bodyIn;
/* gets our result in JSON String */
String ResultObject = resultSOAP.getProperty(0).toString();
resultSOAP = (SoapObject) envelope.bodyIn;
ResultObject = resultSOAP.getProperty(0).toString();
if (ResultObject.startsWith("{")) { // if JSON string is an object
JSONObj = new JSONObject(ResultObject);
Iterator<String> itr = JSONObj.keys();
while (itr.hasNext()) {
String Key = (String) itr.next();
String Value = JSONObj.getString(Key);
BundleResult.putString(Key, Value);
// System.out.println(bundleResult.getString(Key));
}
}
else if (ResultObject.startsWith("[")) { // if JSON string is an array
JSONArr = new JSONArray(ResultObject);
System.out.println("length" + JSONArr.length());
for (int i = 0; i < JSONArr.length(); i++) {
JSONObj = (JSONObject) JSONArr.get(i);
BundleResult.putString(String.valueOf(i), JSONObj.toString());
// System.out.println(bundleResult.getString(i));
}
}
}
catch (Exception exception)
{
}
return null;
}
Hi
Were now testing our application with a few friends. Sometimes there are some errors which dont throw an exception. So I don't really know whats the problem was. So i thought it would be a good idea to implement a menu item which allows to send the logcat file to a email adress, so that we can examine the logcat.
Unfortunately I didnt found a hint in the Internet how to extract the Logcat from a phone. How to send a email shouldn't be the problem.
I have a string with dates it looks like: "20120316 20120317 20120318" ... I store this dates in this format, but I would like to make a Date array from these numbers with the format 03/16 03/17 03/18 ...
So far:
String[] DailyDatasOnce2 = DatesOnce.split(" ");
DailyDatasOnce = new String[DailyDatasOnce2.length];
for (int i=0;i< (DailyDatasOnce2.length) ;i++){
DailyDatasOnce[i]=DailyDatasOnce2[i];
}
datumok = new Date[DailyDatasOnce.length];
for (int i=0;i< (DailyDatasOnce.length) ;i++){
SimpleDateFormat curFormater = new SimpleDateFormat("yyyyMMdd");
java.util.Date dateObj = null;
java.util.Date dateObj2 = null;
try {
dateObj = curFormater.parse(DailyDatasOnce[i]);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SimpleDateFormat postFormater = new SimpleDateFormat("MM/dd");
String newDateStr = postFormater.format(dateObj);
try {
dateObj2 = curFormater.parse(newDateStr);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
datumok[i] = dateObj2;
}
So first I make a string array with the string dates (DailyDatasOnce), maybe that first for loop is useless but i can skip it. Now I make a Date array and I want to put the dates into it. I format the dates to format I want, then I try to convert them to Date format. Until the String newDateStr it is working, I manage to change the type of the date.
But I get syntax error: Type mismatch: Cannot convert from java.util.date to java.sql.data.
I suspect the problem but if it is not possible, how can i do this?
I'm trying to find a way to properly handle setting up an activity where its orientation is determined from data in the intent that launched it. This is for a game where the user can choose levels, some of which are int portrait orientation and some are landscape orientation. The problem I'm facing is that setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) doesn't take effect until the activity is fully loaded. This is a problem for me because I do some loading and image processing during startup, which I'd like to only have to do once.
Currently, if the user chose a landscape level:
the activity starts onCreate(), defaulting to portrait
discovers from analysing its launching Intent that it should be in landscape orientation
continues regardless all the way to onResume(), loading information and performing other setup tasks
at this point setRequestedOrientation kicks in so the application runs through onPause() to onDestroy()
it then again starts up from onCreate() and runs to onResume() repeating the setup from earlier
Is there a way to avoid that and have it not perform the loading twice? For example, ideally, the activity would know before even onCreate was called whether it should be landscape or portrait depending on some property of the launching intent, but unless I've missed something that isn't possible. I've managed to hack together a way to avoid repeating the loading by checking a boolean before the time-consuming loading steps, but that doesn't seem like the right way of doing it. I imagine I could override onSaveInstanceState, but that would require a lot of additional coding. Is there a simple way to do this?
Thanks!
Hi, I have a ListView in a custom ArrayAdapter that displays an icon ImageView and a TextView in each row. When I make the list long enough to let you scroll through it, the order starts out right, but when I start to scroll down, some of the earlier entries start re-appearing. If I scroll back up, the old order changes. Doing this repeatedly eventually causes the entire list order to be seemingly random. So scrolling the list is either causing the child order to change, or the drawing is not refreshing correctly.
What could cause something like this to happen? I need the order the items are displayed to the user to be the same order they are added to the ArrayList, or at LEAST to remain in one static order. If I need to provide more detailed information, please let me know. Any help is appreciated. Thanks.
Hi folks,
I my application I have one large PNG file containg hi-res image. Depending on situation I would like to use this image either as icon or as placeholder for ImageView.
For MenuItem this image is too large, so I need to scale-down it to suitable size. I mean if it has to be displayed on large enough device like Samsung Galaxy Tab - I need to use one scale, for in small ones another, etc. I just noticed that for small-sized devices MenuItem icon is not scaled just cut - which is ugly.
So the question is how should detect which is preferred size?
My application takes userid from user as input, the userid is alphanumeric i.e just the first character is (a-z), other part is numeric. How can I validate input of this type ( like G34555) ?
I'm trying to set up this enum so that it has the ability to return the correct image, though I'm struggling with a way to incorporate the context since it is in a separate class.
public enum CubeType
{
GREEN {
public Drawable getImage()
{
return Context.getResources().getDrawable( R.drawable.cube_green );
}
};
abstract public Drawable getImage();
}
The error I'm getting is:
Cannot make a static reference to the non-static method getResources() from the type Context
final Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("image/jpeg");
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]" });
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "this is the test");
emailIntent.putExtra(Intent.EXTRA_TEXT, "testing time");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
I have used the following code in setting alarm time in AlarmManager class. Now Suppose my device current date 9-july-2012 11:31:00, Now suppose i set set a alarm at 9-july-2012 11:45:00, then it works fine and pop-up an alarm at that time. But if i set an alarm at 10-aug-2012 11:40:00, then as soon as exit the app the alarm pop-up, which is wrong because i set an alarm at month of august, So why this happen, is anything wrong in my code. if anyone knows help me to solve this out.
Code For Setting Alarm time in AlarmManager class
Intent myIntent = new Intent(context, AlarmService.class);
PendingIntent pendingIntent = PendingIntent.getService(context, i, myIntent, i);
AlarmManager alarmManager = (AlarmManager)context.getSystemService(AlarmService.ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.MILLISECOND, (int) dateDifferenceFromSystemTime(NoteManager.getSingletonObject().getAlarmTime(i)));
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
public static long dateDifferenceFromSystemTime(Date date)
{
long difference = 0;
try
{
Calendar c = Calendar.getInstance();
difference = date.getTime() - c.getTimeInMillis();
if (difference < 0)
{
// if difference is -1 - means alarm time is of previous time then current
// then firstly change it to +positive and subtract form 86400000 to get exact new time to play alarm
// 86400000-Total no of milliseconds of 24hr Day
difference = difference * -1;
difference = 86400000 - difference;
}
}
catch (Exception e)
{
e.printStackTrace();
}
return difference;
}
Service class which pop-up alarm when matches time
public class AlarmService extends IntentService
{
public void onCreate()
{
super.onCreate();
}
public AlarmService()
{
super("MyAlarmService");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
super.onStartCommand(intent, startId, startId);
return START_STICKY;
}
@Override
protected void onHandleIntent(Intent intent)
{
startActivity(new Intent(this,AlarmDialogActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
}
I want to create a list like iphone list and HTC hero phone app.
So how can i do that because I tried it with default ListView but I can not make two list in a single layout and ScrollView does not work on it.
So can any body help me about this matter?
I want to parse my json by fromJson class but I am unable to understand what should be the structure of my class if my json is like below:
String json = "{"Result":{"Status":"SUCCESS","Message":""},"Response":{"Token":"ca0d7507-3907-4eed-af19-ad256bc71088","ZoneUrl":"https:\/\/qa.tritononline.com\/","CustomerID":1,"UserID":29,"DefaultLanguageID":1,"ZoneID":1,"IsTritonIntegrated":false,"Language":[{"LanguageId":1,"Language":"English","IsSelected":false}]}}"
This is what I want to do
Response res = new Response();
Gson gson = new Gson();
res = gson.fromJson(json, Response.class);
I want to know what all variable should I take in Response class.
I'm trying to implement filtering using ExpandableListView and SimpleCursorTreeAdapter (its subclass). How can I specify which data (maybe cursor field or TextView text) to use for filtering?
Thanks
I am very new to this, and I more looking for what information I need to study to be able to accomplish this.
What I want to do is use my GUI I have built for my app, but pull the information from a website.
If I have a website that looks like this:
(Sorry, can't post pics yet)
http://
dl.dropbox.com/u/7037695/ErrorCodeApp/FromWebsite.PNG
(full website can be seen at http://www.atmequipment.com/Error-Codes)
What would I need from the website so that if a user entered an error code here:
http://
dl.dropbox.com/u/7037695/ErrorCodeApp/InApp.PNG
It would use the search from the website, and populate the error description in my app?
I know this is a huge question, I'm just looking for what is actually needed to accomplish this, and then I can start researching from there. -- Or is it even possible?