When we are creating albums and uploading related applications, we need to take snapshots of images. At this time, we need to take snapshots of images.
Android has a bitmapfactory class to deal with such requirements.
The implementation steps
Copy codeThe Code is as follows:/** save Method */
Public void saveBitmap (){
Log. e (TAG, "Save image ");
File f = new File ("/sdcard/namecard/", picName );
If (f. exists ()){
F. delete ();
}
Try {
FileOutputStream out = new
Intent, also known as Intent, is a runtime binding mechanism. It can link two different components (Activity, Service, BroadcastReceiver) while the program is running ). With Intent, the program can express a request or willingness to Android.
I have encountered some problems in the display of images recently.1)You can use ImageSwicher and ImageView in combination, so that setfecloud () is used.The worst thing is that if the image size exceeds the screen size, it is difficult to implement.
Modify the following code in \ packages \ apps \ Camera \ res \ values \ arrays. xml:
Copy codeThe Code is as follows:
@ string/pref_camera_continuous_number_normal
@ string/pref_camera_continuous_number_large
40 99
You need to add
As follows:
Copy codeThe Code is as follows: private void readImage (String filename) throws FileNotFoundException, IOException {
FileInputStream fIn = new FileInputStream (filename );
// Replace the following two sentences:Required
1. Create an xml file at drawable/xxx. xml. Remember to put the relevant images in the same directory.
Copy codeThe Code is as follows:
Android: state_selected is selected
Android: state_focused is the focal point
Android: state_pressed:
1. Key code
Copy codeThe Code is as follows: // R. drawable. test is an image of the current project.
Bitmap bitmap = BitmapFactory. decodeResource (getResources (),
R. drawable. test );
FileOutputStream fos = null;
Try
{
File file = new File
First, you can specify the drawing shape when ShapeDrawable is constructed,
Second, you can use shape. getPaint (). setShader (); to specify the Shader. The shader can accept an image and a matrix.
So the problem is solved smoothly :)
The specific
First, you must write the xml file, which is also the most important.
Then, add a thread to the activity with a latency of 2 seconds to jump to the main interface.
The thread code in the activity is as follows: (check whether the network is enabled
A very important mechanism in Android is thread + message. Of course, the thread is not unique to android. Next, let's briefly talk about what should be paid attention to when using the thread.
We use the simplest method to create an android thread +
StartActivity (Intent) is used to redirect activities)But what if the following conditions are met?Activity1 jumps to Activity2, but does it need to return to Activity1 in Activity2? Some people may say: I can use startActivity () again in Activity2.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service