기본 콘텐츠로 건너뛰기

2016의 게시물 표시

Android Studio, JNI, 2 src

* app.gradle android{ ... defaultConfig{ ... ndk { moduleName "ndk-build" } } externalNativeBuild { ndkBuild { path 'jni/Android.mk' } } } * Android.mk LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := GLWaveform LOCAL_SRC_FILES := wave/GLWaveform.cpp wave/TLog.cpp wave/TShader.cpp LOCAL_LDLIBS := -llog -lGLESv2 include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := GLWaveform2 LOCAL_SRC_FILES := wave2/GLWaveform2.cpp wave2/TLog.cpp wave2/TShader.cpp LOCAL_LDLIBS := -llog -lGLESv2 include $(BUILD_SHARED_LIBRARY)

iOS version check

#define SYSTEM_VERSION_EQUAL_TO ( v ) ([[[ UIDevice currentDevice ] systemVersion ] compare : v options : NSNumericSearch ] == NSOrderedSame ) #define SYSTEM_VERSION_GREATER_THAN ( v ) ([[[ UIDevice currentDevice ] systemVersion ] compare : v options : NSNumericSearch ] == NSOrderedDescending ) #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO ( v ) ([[[ UIDevice currentDevice ] systemVersion ] compare : v options : NSNumericSearch ] != NSOrderedAscending ) #define SYSTEM_VERSION_LESS_THAN ( v ) ([[[ UIDevice currentDevice ] systemVersion ] compare : v options : NSNumericSearch ] == NSOrderedAscending ) #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO ( v ) ([[[ UIDevice currentDevice ] systemVersion ] compare : v options : NSNumericSearch ] != NSOrderedDescending ) http://stackoverflow.com/questions/3339722/how-to-check-ios-version

Android, layout background tile

Layout layout = ... Bitmap bmp = BitmapFactory. decodeResource (getResources(), R.drawable. paper0 ); BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(),bmp); bitmapDrawable.setTileModeXY(Shader.TileMode. REPEAT , Shader.TileMode. REPEAT ); layout .setBackgroundDrawable(bitmapDrawable);

Android, simple Fragment sample

* Main ---------------------------------------------------------- ***** xml <? xml version= "1.0" encoding= "utf-8" ?> < LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android :layout_width= "match_parent" android :layout_height= "match_parent" android :orientation= "vertical" xmlns: tools = "http://schemas.android.com/tools" > < LinearLayout android :orientation= "horizontal" android :layout_width= "match_parent" android :layout_height= "wrap_content" > < Button android :layout_width= "wrap_content" android :layout_height= "wrap_content" android :text= "fragment1" android :id= "@+id/button1" android :layout_weight= "1" android :onClick= "selectFrag" /&

Android, access gallery

private static final int REQUEST_PICK_IMAGE = 1 ; protected void ... { ... Intent photoPickerIntent = new Intent(Intent. ACTION_PICK ); photoPickerIntent.setType( "image/*" ); startActivityForResult(photoPickerIntent, REQUEST_PICK_IMAGE ); ... } @Override protected void onActivityResult( final int requestCode, final int resultCode, final Intent data) { switch (requestCode) { case REQUEST_PICK_IMAGE : if (resultCode == RESULT_OK ) { //handle image //data.getData } else { finish(); } break ; default : super .onActivityResult(requestCode, resultCode, data); break ; } }

Android, make Library Project

 ** make aar lib - Create New Project - gradle --  apply plugin : 'com.android.application' -- ->  apply  plugin :  'com.android.library' --  applicationId "xx.xxx.xxxx" -- ->  applicationId  "xx.xxx.xxxx" - Execute Gradle -- -> AAR file ([project name]/app/build/outputs/aar) ref :  http://flowarc.tistory.com/entry/Android-Studio%EC%97%90%EC%84%9C-%EB%82%98%EB%A7%8C%EC%9D%98-Library-%EB%A7%8C%EB%93%A4%EC%96%B4%EB%B3%B4%EA%B8%B0

Google Analytics v3, INSTALL_REFERRER

AndroidManifest.xml < service android :name= "com.google.analytics.tracking.android.CampaignTrackingService" /> < receiver android :name= "com.google.analytics.tracking.android.CampaignTrackingReceiver" android :exported= "true" > < intent-filter > < action android :name= "com.android.vending.INSTALL_REFERRER" /> </ intent-filter > </ receiver > https://developers.google.com/analytics/devguides/collection/android/v3/campaigns#google-play-implement

Android, Spinner, DropDownList

final Spinner fontSizeSpinner = (Spinner)dialog.findViewById(R.id. dialog_setting_fontsize_spinner ); { // font size fontSizeTitle.setText(act.getString(R.string. setting_fontsize_title ).toString()); List<String> list = new ArrayList<String>(); list.add(act.getString(R.string. setting_fontsize_3_label )); list.add(act.getString(R.string. setting_fontsize_2_label )); list.add(act.getString(R.string. setting_fontsize_1_label )); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout. simple_spinner_item , list); dataAdapter.setDropDownViewResource(android.R.layout. simple_spinner_dropdown_item ); fontSizeSpinner.setAdapter(dataAdapter); }

AndroidStudio, Gradle, apk name debug/release

android { ... buildTypes { debug { ... } release { ... } applicationVariants.all { variant -> variant.outputs.each { output -> def apkName = "" def formattedDate = new Date().format( 'yyyyMMdd' ) if (variant.buildType.name == "release" ){ apkName = "AppName_" + variant.versionName + "_" + formattedDate + ".apk" } else { apkName = "AppName_dev" + variant.versionName + "_" + formattedDate + ".apk" } output.outputFile = new File(output.outputFile.parent, apkName) } } }

Android Studio, debug/release. values

string value. debug/release ------------------------------------------------ AndroidManifest.xml ... < meta-data android:name = "com.pkg.myp" android:value = "@string/a_string" / > ... src/debug/res/values/aaa.xml ... < string name = "a_string" > debugValue < / string > ... src/release/res/values/aaa.xml ... < string name = "a_string" > releaseValue < / string > ... src/main/res/values/aaa.xml < ?xml version = "1.0" encoding = "utf-8" ? > < resources xmlns:tools = "http://schemas.android.com/tools"   tools:ignore = "MissingTranslation" > <!-- translate err when make apk. add MissingTranslation --> ... ------------------------------------------------------------------------------

Android, GoogleMap V2, custom InfoWIndow

map.setInfoWindowAdapter( new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker arg0) { //use custom window include infoWindow style. return null ; } @Override public View getInfoContents(Marker arg0) { //call when getInfoWindow returns null //use custom window with default infoWindow style. return null ; } });

Android, delete directory

public static void deleteRecursive(File fileOrDirectory) { if (fileOrDirectory.isDirectory()) for (File child : fileOrDirectory.listFiles()) deleteRecursive (child); fileOrDirectory.delete(); } ref http://stackoverflow.com/questions/3775694/deleting-folder-from-java

linux, install Android Studio

* Android Studio download url http://developer.android.com/intl/ko/sdk/index.html * install java and setting http://stackoverflow.com/questions/17033726/android-studio-error-after-studio-sh * remove open java sdk and download from oracle (Kr) https://opentutorials.org/module/516/5558

Android, Notification, simple implement

//Android API 15 ↑ IssueListActivity act = AActivity. this ; NotificationManager nm = (NotificationManager) getSystemService(Context. NOTIFICATION_SERVICE ); Intent i = new Intent(Intent. ACTION_VIEW , Uri. parse ( "http://www.google.com" )); PendingIntent pendingIntent = PendingIntent. getActivity (act, 0 , i, 0 ); Notification.Builder mBuilder = new Notification.Builder(act); mBuilder.setSmallIcon(R.drawable. icon ); mBuilder.setTicker( "Hello Notification" ); mBuilder.setWhen(System. currentTimeMillis ()); mBuilder.setNumber( 10 ); mBuilder.setContentTitle( "title" ); mBuilder.setContentText( "content msg" ); mBuilder.setDefaults(Notification. DEFAULT_SOUND | Notification. DEFAULT_VIBRATE ); mBuilder.setContentIntent(pendingIntent); mBuilder.setAutoCancel( true ); nm.notify( 1 , mBuilder.getNotification());

Android, SharedPreferences, store Object, sample

//Test : obj( ArrayList<Map>) public static void saveObj (Context context, Object obj){ SharedPreferences. Editor editor = context. getSharedPreferences (STORAGE_KEY, 0 ). edit (); Gson gson = new Gson(); String json = gson. toJson (obj); editor. putString (OBJ_KEY, json); editor. commit (); } public static Object loadObj (Context context){ SharedPreferences prefs = context. getSharedPreferences (STORAGE_KEY, 0 ); String json = prefs. getString (OBJ_KEY, null ); Gson gson = new Gson(); Object obj = gson. fromJson (json, Object. class ); return obj; }

Android, Device unique key

** required : cellular model chip TelephonyManager tManager = (TelephonyManager)getSystemService(Context. TELEPHONY_SERVICE ); String uuid = tManager. getDeviceId (); ** required : WiFi on WifiManager manager = (WifiManager) getSystemService(Context. WIFI_SERVICE ); WifiInfo info = manager. getConnectionInfo (); String address = info. getMacAddress (); ** required :  Android 4.0 (API 14) String uuid = Build. SERIAL ;

Android, no title bar, no status bar

** styles.xml   add < item name= "windowNoTitle" >true</ item > < resources > < style name= "AppTheme" parent= "Theme.AppCompat.Light.DarkActionBar" >     ... < item name= "windowNoTitle" >true</ item > //add this line </ style > </ resources > < item name= "windowNoTitle" >true</ item > -> no title bar only. < item name= "windowFullscreen" >true</ item > -> no status bar.

linux, format ext3

$ sudo -s # fdisk -l # umount /dev/sdb1 # fdisk /dev/sdb n p # mke2fs -c /dev/sdb1 # tune2fs -j /dev/sdb1 # e2label /dev/sdb1 sdcardvolume # chown -R user:user /media/sdcard ref :  http://tungchingkai.blogspot.jp/2008/01/format-sd-card-to-linux-filesystem-in.html