<uses-permission android:name="android.permission.INTERNET" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:id="@+id/lblText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> </RelativeLayout>
import com.microsoft.windowsazure.mobileservices.MobileServiceClient;
package com.example.myappmobileservice; import java.net.MalformedURLException; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.TextView; import com.microsoft.windowsazure.mobileservices.MobileServiceClient; public class MainActivity extends Activity { private MobileServiceClient mClient; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { mClient = new MobileServiceClient( "https://thaicreate.azure-mobile.net/", "JbRsrGvytUSWWmfKkoqukDmLYzERpl40", this ); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } final TextView lbText = (TextView) findViewById(R.id.lblText); if (mClient == null) { lbText.setText("Android Connect Failed"); } else { lbText.setText("Android Connected to Mobile Servie"); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท