Android :: Call OnDraw In Another Method - Then - Refresh - That Call In Another Method
Jun 6, 2010
Basically I'm calling the onDraw method like so...
code:...................
You see I'm drawing it on top of a Camera view and the information being drawn is subject to change. I have a listener setup which will update the variables being drawn at the appropriate time but I now want to "refresh" this draw in that listener.
View 1 Replies
Apr 21, 2010
I'm trying to modify the SurfaceView I use for doing a camera preview in order to display an overlaying square. However, the onDraw method of the extended SurfaceView is never called.
View 3 Replies
View Related
Aug 21, 2010
I am looking to run a certain method call every ten minutes in Android, what is the best way to go about implementing this? I am currently looking at using the Handler object's PostDelayed method.
View 1 Replies
View Related
Apr 21, 2009
I have a java class Poker.java and an Activity .GameWindow in GameWindow.Java. In the GameWindow activity i have a method...
View 2 Replies
View Related
Aug 28, 2009
You need a reference to the class that contains the method you want to call. To access the method homepage() inside the eSkyGuide from the class Weather, you need an instance of the eSkyGuide class inside the instance of the Weather class.
View 4 Replies
View Related
Jun 18, 2010
I want to be able to call the following method after a specified delay. In objective c there was something like:
[self.performSelectorAfterDelay @selector(DoSomething) with Object:nil afterDelay:5];
Is there an equivalent of this method in java? For example I need to be able to call a method after 5 seconds. Code...
View 6 Replies
View Related
Jan 31, 2010
How can i call the onUpgrade Method of the database? Background of my question: I do a backup on the sdcard of the full database. And the user can restore this database. But if in the meantime (between backup and restore) an app update has made changes to the database i get a problem on restoring. The new columns are not there after restoring. So i want to call the onUpgrade method to add all new/changed columns. Or is there a better way for this?
View 1 Replies
View Related
Oct 5, 2010
I am a beginner in Android Developing. Can any1 please guide me how to call a Method of a class kept under other package. Like class A in Package 1 calls a method in Class B of Package 2 which returns An array or object. Do i have to create an Intent for that? actually i have to gather all information in 1 class from different classes kept under different packages.
View 2 Replies
View Related
Jan 30, 2010
For Android, I have a custom view which I fill up with primitive shapes in the onDraw() method. Coming from a Processing background, I expected the draw method to be called automatically 30 times per second, but its clear that that's not how android views work. So how should I go about calling this method 30 times per second?
View 1 Replies
View Related
Sep 18, 2010
I am writing a basic game engine and have an abstract class that represents any object that can be drawn in the 3D world, however inside this class is an abstract method Render() which I would like called automatically by the engine on each draw phase.
How could I implement this so that every class extending from my abstract class will automatically have Render() called? I am using java, android sdk 2.2, and opengl es
View 4 Replies
View Related
Sep 16, 2010
I have an Activity which contains a ListView defined in XML (its not subclassing the List Activity class).I want to display a message when the ListView is empty, so I tried doing so with the setEmptyView method: Code...
View 2 Replies
View Related
Aug 1, 2009
The following code leads to "java.lang.IllegalThreadStateException: Thread already started." the second time it is run through on the program This happens the second time updateUI.start() is called. I've stepped through it multiple times and the thread is called and completely runs to completion before hitting updateUI.start(). Calling updateUI.run() avoids the error but causes the thread to run in the UI thread (the calling thread, as mentioned in other posts on SO), which is not what I want. Can a Thread be started only once? If so than what do I do if I want to run the thread again? This particular thread is doing some calculation in the background, if I don't do it in the thread than it's done in the UI thread and the user has an unreasonably long wait.
View 5 Replies
View Related
Oct 30, 2009
I have following problem: I have my "MainActivity". In this Activity, i start a thread (SaxParser in another "normal" java file). Now I want to call a method from the MainActivity out of the normal java file? I have read something of an Application object, but i only find things, where i have to create a new Intent. Is it possible to use the application object in the other "normal" java file like that: Code...
View 5 Replies
View Related
Oct 15, 2009
JNI problem : from c Languege call Java. i think from c Language call Java, but that CallIntMethod() return value is not equals getIpv6() -> 99, CallIntMethod() its always return strange value is [-1091242504] or [11212] . additional i already solve [Method not found: Code...
View 3 Replies
View Related
Apr 21, 2010
Is there a easy way to initiate a call from a button in an Android app?
You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
View 2 Replies
View Related
Nov 19, 2010
I want to call a bitmap from a method in my main class and am unsure how to do it - I have a method: Code...
So basically, how can I place the bitmap in my detectFaces method in my main class and pass it as a bitmap on my imageview in my false class?
View 2 Replies
View Related
Jun 3, 2012
So how can I create a custom method.I have several image buttons that I need to change the characteristics of such as an image when it is pushed and when it is not pushed. So when I push one button it changes to a pushed image for that button and ALL other buttons revert to an unpushed image. Currently I have to have this code in every button click method I would LOVE to create one method that I can call from each button click method that way if I have to change anything it is in one place.
I would love to when a button is tapped
call the custom method to revert all buttons to unpushed
then change the button being tapped to pushed
A very common process but I can't figure out how to write the custom method and then call it,,calling it should be simple something like custommethod.
View 2 Replies
View Related
May 17, 2012
2.3.3 CheckBox
I want onchange(CheckBox) call a method, well what listener to use? like EditView's TextWatcher but for CheckBox,... // what methods require implemented(give urls)...?
Code:
personsEditText.addTextChangedListener(personsEditTextWatcher);
private TextWatcher personsEditTextWatcher = new TextWatcher()
{
...
}
View 1 Replies
View Related
Oct 18, 2010
I've been trying to call a non-static method, located in my main application Class, from the Preferences Class. Because the method I call is not static, I instantiate the main class and then try to call the specific method I want but it's force closing.
Preferences.class (from where I call the method):
Preference sorted = (Preference) findPreference("sortPref");
sorted.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
Object d = new Dmarks();
((Dmarks) d).queryBookmarks();
return true;
}});
the Dmarks.class method I call:
public void queryBookmarks() {
Toast.makeText(context, Toast.LENGTH_LONG).show();
//context is not null and the Toast is working if I call it from Dmarks.class }
The Logcat:
E/AndroidRuntime(11718): FATAL EXCEPTION: main
E/AndroidRuntime(11718): java.lang.NullPointerException
E/AndroidRuntime(11718):
at android.content.ContextWrapper.getContentReso
lver(ContextWrapper.java:90)
E/AndroidRuntime(11718):
at android.app.Activity.managedQuery(Activity.ja
va:1520)
E/AndroidRuntime(11718):
at com.droidil.droidmarks.Dmarks.queryBookmarks(
Dmarks.java:101)
E/AndroidRuntime(11718):
at com.droidil.droidmarks.Preferences$2.onPrefer
enceChange(Preferences.java:47)
E/AndroidRuntime(11718):
at android.preference.Preference.callChangeListe
ner(Preference.java:756)
E/AndroidRuntime(11718):
at android.preference.ListPreference.onDialogClo
sed(ListPreference.java:219)
E/AndroidRuntime(11718):
at android.preference.DialogPreference.onDismiss
(DialogPreference.java:384)
E/AndroidRuntime(11718):
at android.app.Dialog$ListenersHandler.handleMes
sage(Dialog.java:1047)
E/AndroidRuntime(11718):
at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime(11718):
at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(11718):
at android.app.ActivityThread.main(ActivityThrea
d.java:4627)
E/AndroidRuntime(11718):
at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(11718):
at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime(11718):
at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(11718):
at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:626)
E/AndroidRuntime(11718):
at dalvik.system.NativeStart.main(Native Method)
D/dalvikvm(11718): GC_FOR_MALLOC freed 4248 objects / 282248 bytes in 40ms
W/ActivityManager( 244): Force finishing activity com.droidil.droidmarks/.Preferences
View 5 Replies
View Related
Nov 7, 2010
In my program I have a custom view object. Inside the view class is a method called foo. For some reason when I call foo from my activity, it doesn't fire. Here is the code:
XML of the custom view:
<com.company.application.MyView android:id="@+id/my_view" android:layout_width="wrap_content" android:layout_height="wrap_content" />
The activity code:
public class Main extends Activity { MyView mView;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main);
LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = li.inflate(R.layout.main, null); mView= (MyView) v.findViewById(R.id.my_view);
//A button to fire the method inside foo() Button switchLeft = (Button) findViewById(R.id.switch_left); switchLeft.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { callTest(); } } );
} public void callTest() { Log.w(this.getClass().getName(), "clicked left arrow");
mView.foo(); mView.postInvalidate();
} }
Finally here is foo:
public void foo() { mBackground = mContext.getResources().getDrawable(R.drawable.temp_canvas); Log.w(this.getClass().getName(), "background set");
}
The first log is always written when the button is pressed, but the second log is not because foo never fires. What is the deal here? Upon request, the full view
public class MyView extends View { Drawable mBackground; Context mContext;
public MyView (Context context) { super(context); mContext = context;
mBackground = mContext.getResources().getDrawable(R.drawable.leftarrow1);
} public MyView (Context context, AttributeSet attrs) {
super(context, attrs); mContext = context;
mBackground = mContext.getResources().getDrawable(R.drawable.leftarrow1);
} public void foo() { mBackground = mContext.getResources().getDrawable(R.drawable.temp_canvas);
Log.w(this.getClass().getName(), "background set"); }
@Override public void onDraw(Canvas canvas) { Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL); // draw a solid blue circle
paint.setColor(Color.BLUE); canvas.drawCircle(20, 20, 15, paint);
// draw a test background mBackground.setBounds(0, 0, 300, 400);
mBackground.draw(canvas); }
}
View 1 Replies
View Related
Jun 14, 2010
I want to know when a close method of a sqlite database should be called in a life cycle, since the NotePad sample in the sdk (http://developer.android.com/resources/tutorials/notepad/index.html) doesn't call NotesDbAdapter.close(), it implements that method though.
My application accesses the db not so frequently, but some, it depends on user requests. I think I should open the db at the onCreate, and close it at the onDestroy. Is that a good practice?
View 1 Replies
View Related
May 31, 2010
I would like to know if is there a way to call android:layout_gravity property from a java method. I didn't found any method in Android documentation to do it. This is the picture of the layout I want to implement: But in my situation, I need to do it through Java code, because I'll implement another layout views dinamically. To avoid merging xml layout with Java code, I would prefer make all layout using Java. Code...
View 2 Replies
View Related
Aug 8, 2010
I am using the following method in a new application I'm developing. There is a main activity, which instantiates different classes that extends RelativeLayout and I'm using setContentView to switch between the different modules of the application. I wonder if this is a good approach or necessarily I have to use different activities to the several screens the app haves.
View 1 Replies
View Related
Oct 27, 2010
If I change one imageview's source to another (and thus changing the image) but then have more changes occur within the method and such. How do I force it to refresh to show the changes before the method ends? (As waiting for the method to end to show the changed images is not good for my purposes at all)
View 1 Replies
View Related
Dec 3, 2009
I'm using a class extends with view. I'm using timer in that class. I'm using onTouchEvent() also. I onTouchEvent() I'm using invalidate(). So it is calling onDraw(). When i use invalidate() in Timer. It is not calling onDraw().
View 8 Replies
View Related
Mar 30, 2010
i want to display a msg to the user (msg box or Toast) when exception happend in a static SQLite Database class that i use. the problem is that i cant call a non static method in a static class , how can i handle this. this is the class
private static SQLiteDatabase getDatabase(Context aContext) {
and i want to add something like this in the class when exception happen but context generates the problem of reference to non static in static class.
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
View 1 Replies
View Related
Mar 16, 2009
I'm trying to call a java method from javascript using addJavascriptInterface(); but seems does not work, it always display "failure"; java code...
View 2 Replies
View Related
Sep 7, 2010
I'm trying to override the onBackPressed() method of the ActivityGroup class:
public class MyClass extends ActivityGroup {
@Override
public void onBackPressed() {
// do something
return;
}
but I'm getting the error The method onBackPressed() of type MyClass must override a superclass method. I'm relatively new to Java, I've seen here that people do it and it works for them Why I'm getting this error? I'm writing an app for android 1.5, could the problem be here?
View 1 Replies
View Related
Nov 22, 2010
In Eclipse, when I mouse hover over a built-in method, it displays a method definition including stuff like what the method does, input objects, return objects etc. If I have a yellow line (warning) under the method I'm trying to use, I can't get the mouse-over to show the definition. If I try hitting F3, I get a "The Jar of this class file belongs to container "Android 1.6" How do I show the definition of the method I am using when there is a warning?
View 1 Replies
View Related
May 12, 2010
I am trying to use annotation - method.getAnnotation( ) or method.isAnnotationPresent( ) and it is not working. I am using eclipse emulator for 2.1 OS version with JDK 1.6. Following is information about what I did..................
View 4 Replies
View Related