This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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:focusable="true" | |
| android:focusableInTouchMode="true" > | |
| <requestFocus /> | |
| <ListView |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class QuizModel { | |
| public String strQuiz = null; | |
| public String strAnwser = null; | |
| public QuizModel(String strQuiz, String strAnwser) { | |
| this.strQuiz = strQuiz; | |
| this.strAnwser = strAnwser; | |
| } | |
| public String getQuiz() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void appendTextFile(String text) { | |
| File file = new File("sdcard/text.txt"); | |
| if (!file.exists()) { | |
| try { | |
| file.createNewFile(); | |
| } catch (IOException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package app.akexorcist.googledapsample; | |
| import org.w3c.dom.Document; | |
| import com.google.android.gms.maps.CameraUpdateFactory; | |
| import com.google.android.gms.maps.GoogleMap; | |
| import com.google.android.gms.maps.SupportMapFragment; | |
| import com.google.android.gms.maps.model.BitmapDescriptorFactory; | |
| import com.google.android.gms.maps.model.LatLng; | |
| import com.google.android.gms.maps.model.MarkerOptions; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Button btn1 = (Button)findViewById(R.id.btn1); | |
| btn1.setOnClickLlistener(new OnClickListener() { | |
| public void onClick(View v) { | |
| // Button 1 Command | |
| } | |
| }); | |
| Button btn2 = (Button)findViewById(R.id.btn2); | |
| btn2.setOnClickLlistener(new OnClickListener() { | |
| public void onClick(View v) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public int dpToPx(Context context, int dp) { | |
| DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); | |
| int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); | |
| return px; | |
| } | |
| public int pxToDp(Context context, int px) { | |
| DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); | |
| int dp = Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); | |
| return dp; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ConnectivityManager cm = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); | |
| NetworkInfo netInfo = cm.getActiveNetworkInfo(); | |
| if (netInfo != null && netInfo.isConnected()) { | |
| try { | |
| URL pingUrl = new URL("http://www.google.com"); | |
| HttpURLConnection urlc = (HttpURLConnection)pingUrl.openConnection(); | |
| urlc.setConnectTimeout(3000); | |
| urlc.connect(); | |
| if (urlc.getResponseCode() == 200) { | |
| // ผู้ใช้ต่อเนตและใช้งานได้ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:shape="oval" > | |
| <solid android:color="@color/light_green" /> | |
| </shape> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PackageManager pm = getPackageManager(); | |
| Intent main = new Intent(Intent.ACTION_MAIN, null); | |
| main.addCategory(Intent.CATEGORY_LAUNCHER); | |
| List<ResolveInfo> packages = pm.queryIntentActivities(main, 0); | |
| ArrayList<String> app_name_list = new ArrayList<String>(); | |
| ArrayList<String> app_package_list = new ArrayList<String>(); | |
| for(ResolveInfo resolve_info : packages) { | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Bitmap resizeBitmap(Bitmap bm, int maxWidth, int maxHeight) { | |
| int newWidth, newHeight; | |
| int bmWidth = bm.getWidth(); | |
| int bmHeight = bm.getHeight(); | |
| if(bmWidth > maxWidth && (maxWidth * bmHeight) / bmWidth < maxHeight) { | |
| newWidth = maxWidth; | |
| newHeight = (maxWidth * bmHeight) / bmWidth; | |
| } else { | |
| newWidth = (maxHeight * bmWidth) / bmHeight; | |
| newHeight = maxHeight; |
OlderNewer