TouchPaint Android API - java

All I am trying to do is use this API to write on the screen.
I am very new to programming, I can run this code, and play with it, but which class would I need to edit if I wanted to add a save button to it.
Once you draw something you would save it to your phone, how would I do this?
Can you point me to some code please?
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html

Related

Why does an activity playing a sound disturb the user interface?

I would like to show a notification and play a sound when the user taps onto that notification. It works somehow when I use an activity to play the sound, as I have written in my own answer to this question: How can I create a notification that plays an audio file when being tapped? (in this question and answer there is also the source code showing how I create the notification and how my PlaySoundActivity looks like.
Yet, I have realized, that while the sound is playing, the appearance of my main application changes and it will not be restored without closing the application.
I have created my application from the "Tabbed Activity" project template.
This is how it looks after being started:
And this is how it looks when I have tapped onto the sound notification (the sections are gone):
Can anyone explain why this happens? Is it a wrong approach to play sound using an activity? But it does not work here when I use a service, I hear nothing! How to solve that?
According to the Android developer reference, "almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View)".
I had not done this. Therefore a new window was displayed, but there was no content.
The better solution for playing a sound is to use a PlaySoundService (service!!!) instead of an activity. It contains almost the same code as an activity would do, but the pending intent is created with PendingIntent.getService(...) instead of PendingIntent.getActivity(...). Using the wrong method does not result in an obvious error message, but the service won't work as expected.

How to get image from PhotoEditor SDK

I am trying to integrate my project with PESDK. I need to get image that is currently in the editor. I found that PESDK has R.id.editorImageView. This is object of EditorPreview class which isn't an extension of ImageView. So I didn't understand how to extract the image. Because of word Preview I suppose that PESDK do not apply immediately all changes to the image and in the end after pressing default AcceptButton of PESDK it runs final calculations and saves this image.
Is there any way that I can emulate this action? I just need to get Bitmap in the memory without saving it.
If there is no such way then I think the one possible solution is to call onClick of default AcceptButton and notify my code that it was pressed myButton, not AcceptButton. Then read saved image, process it and then delete file. I'm quite new in Android and if you know how to do this notification (that it was myButton pressed) then please share your knowledge.
Thank you for any help or advice!

Android Program Modification

I'm currently working on my first android project, which is to modify an existing sample program ("Tic Tac Toe" game). I'm going through the tutorials on the official website, but looking at the sample code I don't think I'll be able to figure everything out on my own in the time I have.
The modifications include being able to select a custom background, setting up a scoring system, and implementing a timed "blitz" mode. My basic questions are:
In which subfolder would the code that sets the background color/image for the game be?
Is there a way to create an Intent function that opens up a file search window to allow a user to select this custom background image?
I'd like to start here, I'm sure I'll have more questions as I go along. As always, any help is appreciated. (By the way, the code from the game is from the standard sample problems that come installed with the Android SDK for Eclipse).
Update 1:
So far I found this in a class called GameView:
mDrawableBg = getResources().getDrawable(R.drawable.lib_bg);
setBackgroundDrawable(mDrawableBg);
mDrawableBg is a Drawable object, I'm not sure what this part is refrencing:
R.drawable.lib_bg
What would be the proper way to modify the background in this piece of the code?
Update 2:
Here's where I'm at:
I have the getDrawable function taking another function as an argument:
mDrawableBg = getResources().getDrawable(getImage());
getImage() is suppose to return a integer referencing the selected image, here is the code (so far) for that function:
public int getImage(){
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, 10);
}
This is suppose to open the gallery and let the user select an image, I'm not sure how to return a reference ID to that selected image though. Also, the startActivityForResult function is not working properly, I don't think I'm using the Activity class properly.
The background is probably defined as either a drawable (in /res/drawable-*) or a color value (in /res/values/colors.xml or something like that). It will be referenced in one of the layout files in /res/layout. The layout file will be referenced by one of the activity classes in the Java source folders.
You can declare in code an array of drawable resource IDs and use that to dynamically generate a dialog and/or activity. The HorizontalScrollView widget might be useful for this. If you start a selection activity with an intent, use startActivityForResult instead of startActivity. You can then set the background of your top view using setBackgroundResource().

How to draw sound in android

I'm creating an app on android in java, very simple, which has a button that on click play a sound.
I want to create a sort of canvas to draw something like sinusoide of music.. i hope i've been clear..
Do you know something about this?
look at this Api Demp it may help u.

ImageView, selecting a certain part Android

My vision is this-- I have an image of a human body(like an anatomy chart), and I want the user to be able to click a certain part of it and be able to communicate the body part they have clicked on, as in translating it to text... I wonder if this could be possible, and how? Any sample code/redirection to a tutorial would be helpful, or maybe just a practical idea...
A very simple approach is just to add an ImageView to you layout.
Override onTouchEvent in the activity to capture touches and then translate the coordinates to texts.

Categories

Resources