Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > Android สอบถามเรื่อง capture photo แล้วจะอัพขึ้น server ใช้ code ตัวไหนครับ



 

Android สอบถามเรื่อง capture photo แล้วจะอัพขึ้น server ใช้ code ตัวไหนครับ

 



Topic : 092576



โพสกระทู้ ( 51 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์




สอบถามเรื่อง capture photo แล้วจะอัพขึ้น server ใช้ code ตัวไหนครับ

พอจะมีตัวอย่างไหมครับ ขอบคุณครับ

อันนี้โค้ด capture image
Code (Android-Java)
public class travel_menu_add extends Activity {
	    private static final int CAMERA_REQUEST = 1888; 
	    private ImageView imageView;
	    private static final int SELECT_PHOTO = 1;
	    
	    @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.travel_menu_add);
	        this.imageView = (ImageView)this.findViewById(R.id.imageView1);
	        Button photoButton = (Button) this.findViewById(R.id.button1);
	        
	        
	        photoButton.setOnClickListener(new View.OnClickListener() {

	            @Override
	            public void onClick(View v) {
	                Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
	                startActivityForResult(cameraIntent, CAMERA_REQUEST); 
	            }
	        });
	        
	        Button bt = (Button)findViewById(R.id.pic);
	        bt.setOnClickListener(new OnClickListener() {

	            public void onClick(View arg0) {
	            	
	            	Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
	            	photoPickerIntent.setType("image/*");
	            	startActivityForResult(photoPickerIntent, SELECT_PHOTO);    
	            }
	        });
	    }

	    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
	        if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {  
	            Bitmap photo = (Bitmap) data.getExtras().get("data"); 
	            imageView.setImageBitmap(photo);
	        }  
	    } 
	}


อันนี้หน้าจอ
Code (XML)
<ScrollView
            android:id="@+id/scrollView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            xmlns:android="http://schemas.android.com/apk/res/android"
    		xmlns:tools="http://schemas.android.com/tools"
    		xmlns:foo="http://schemas.android.com/apk/res/com.travel">
            
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FF00FF"
    android:baselineAligned="false"
    android:clipToPadding="false"
    android:measureWithLargestChild="false"
    android:orientation="vertical" >
    
    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@color/title_background"
        android:gravity="center_horizontal" >

        <LinearLayout
            android:id="@+id/panelIconLeft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_margin="5dp" >

            <Button
                android:id="@+id/btnHome"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="center_horizontal"
                android:background="@drawable/ic_launcher"
                android:onClick="btnHomeClick" />

        </LinearLayout>

        <com.travel.TextViewPlus
            android:id="@+id/txtHeading"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:layout_centerInParent="true"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_toLeftOf="@+id/panelIconRight"
            android:layout_toRightOf="@id/panelIconLeft"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="center"
            android:marqueeRepeatLimit="marquee_forever"
            android:singleLine="true"
            android:text="ผู้ใช้งานทั่วไป"
            android:textColor="@android:color/white"
            android:textSize="15sp"
            foo:customFont="THSarabunBold.ttf" >

        </com.travel.TextViewPlus>

        <LinearLayout
            android:id="@+id/panelIconRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_margin="5dp" >

            <Button
                android:id="@+id/btnFeedback"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="center_horizontal"
                android:background="@drawable/ic_feedback"
                android:onClick="btnFeedbackClick" />

        </LinearLayout>

    </RelativeLayout>
    
    
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FF00FF"
        android:orientation="vertical"
        android:padding="20dp" >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@drawable/round" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginBottom="10dp"
            android:text="เพิ่มข้อมูลสถานที่ท่องเที่ยว" />

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="150dp"
            android:layout_height="100dp"
            android:layout_gravity="center_horizontal" />

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TakePic" />

        <Button
            android:id="@+id/pic"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="เลือกรูป" />

        <Button
            android:id="@+id/btnUpload"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:text="Upload" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="ชื่อสถานที่ท่องเที่ยว" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:ems="10" >
        </EditText>

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="ประเภทสถานที่ท่องเที่ยว" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:ems="10" >
        </EditText>

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="รายละเอียด" />

        <EditText
            android:id="@+id/editText3"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:ems="10"
            android:inputType="textPostalAddress" >
        </EditText>

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="งบประมาณ" />

        <EditText
            android:id="@+id/editText4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10" >
        </EditText>

        <TextView
            android:id="@+id/textView6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="จังหวัด" />

        <EditText
            android:id="@+id/editText5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10" />

    </LinearLayout>
	
    </LinearLayout>
	 
    

</LinearLayout>
</ScrollView>




Tag : Mobile, Android







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-03-17 15:08:46 By : nutsai4 View : 1340 Reply : 5
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ดู 2 บทความนี้ครับ



Go to : Android Capture Image and Camera Capture Screenshot (android.view.SurfaceView)
Go to : Android Upload Send file to Web Server (Website)






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-17 15:45:54 By : mr.win
 


 

No. 2



โพสกระทู้ ( 51 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ผมได้แล้วครับ จาก Code นี้

Code (Android-Java)
class ImageUploadTask extends AsyncTask <Void, Void, String>{
		String err=null;
		@Override
		protected String doInBackground(Void... unsued) {
			
			try {
				ByteArrayOutputStream bos = new ByteArrayOutputStream();
				bitmap.compress(CompressFormat.JPEG, 75, bos);
				byte[] data = bos.toByteArray();
				
				HttpClient httpClient = new DefaultHttpClient();				
				HttpPost postRequest = new HttpPost(PHP_URL);	
				
				
				ByteArrayBody bab = new ByteArrayBody(data,file_name);				
				MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
				
				reqEntity.addPart("uploadedfile", bab);
				reqEntity.addPart("nameTravel", new StringBody(NameTravel.getText().toString().trim()));
				reqEntity.addPart("travelType", new StringBody(spin_type_travel.getSelectedItem().toString().trim()));
				reqEntity.addPart("descriptionTravel", new StringBody(Description.getText().toString().trim()));
				reqEntity.addPart("moneyTravel", new StringBody(Money.getText().toString().trim()));
				reqEntity.addPart("province", new StringBody(spin_province.getSelectedItem().toString().trim()));
				reqEntity.addPart("vote1", new StringBody(Integer.toString(vote1.getProgress()).toString().trim()));
				reqEntity.addPart("vote2", new StringBody(Integer.toString(vote2.getProgress()).toString().trim()));
				reqEntity.addPart("vote3", new StringBody(Integer.toString(vote3.getProgress()).toString().trim()));
				reqEntity.addPart("vote4", new StringBody(Integer.toString(vote4.getProgress()).toString().trim()));
				reqEntity.addPart("vote5", new StringBody(Integer.toString(vote5.getProgress()).toString().trim()));
				reqEntity.addPart("latitude", new StringBody(getLatitude.getText().toString().trim()));
				reqEntity.addPart("longitude", new StringBody(getLongitude.getText().toString().trim()));
				
				
				postRequest.setEntity(reqEntity);
				HttpResponse response = httpClient.execute(postRequest);
				BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(),"UTF-8"));
				String sResponse;
				StringBuilder s = new StringBuilder();

				while ((sResponse = reader.readLine()) != null) {
					s = s.append(sResponse);
				}
				
				return s.toString().trim();
			
			} catch (Exception e) {
				
				err="error"+e.getMessage();
				Log.e(e.getClass().getName(), e.getMessage());
				
				return e.getMessage();
			}				
		}

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-20 14:28:54 By : nutsai4
 

 

No. 3



โพสกระทู้ ( 51 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ตอบความคิดเห็นที่ : 2 เขียนโดย : nutsai4 เมื่อวันที่ 2013-03-20 14:28:54
รายละเอียดของการตอบ ::
จาก Code ด้านบน ผมส่ง ข้อมูลไป มันไม่เป็นภาษาไทย อ่ะครับ มันเป็น ?????
ถ้าจะใส่ Code นี้ จะเพิ่ม ตรงไหนครับ httpPost.setEntity(new UrlEncodedFormEntity(params,"UTF-8"));

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-20 14:30:31 By : nutsai4
 


 

No. 4



โพสกระทู้ ( 51 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ได้แล้วครับ

ให้เพิ่ม

Code
Charset chars = Charset.forName("UTF-8");


แล้วก็ไม่ใส่ใน parameter อย่างนี้ครับ

Code
reqEntity.addPart("descriptionTravel", new StringBody(Description.getText().toString().trim(),chars));

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-20 14:51:39 By : nutsai4
 


 

No. 5



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

จัดไป
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-20 17:13:00 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : Android สอบถามเรื่อง capture photo แล้วจะอัพขึ้น server ใช้ code ตัวไหนครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่