프로그램/Android 2013. 3. 12. 10:31

안드로이드 토스트 연속 출력 및 위치 지정하기


//선언
 
static Toast mtoast;
 
 
 
// 사용
 
void toastprint(string string){
 
 
 
 if (mtoast == null) {
    mtoast = Toast.makeText(mContext, string, length);
   } else {
    mtoast.setText(string +"set");
   }
 

       int offsetX = 10;
       int offsetY = 10;
       mtoast.setGravity(Gravity.CENTER, offsetX, offsetY);
       mtoast.show(); 

}

프로그램/Android 2013. 3. 12. 00:03

디버깅빠르게 하기 aapt

디버깅빠르게 하기 aapt

출처 : http://forum.xda-developers.com/showthread.php?t=1907281

다운로드 (익스플로러로 다운 잘안됨): http://forum.xda-developers.com/attachment.php?attachmentid=1368522&d=1349123034

Presenting: Fast AAPT - aka FAAPT

Lately Android development has been getting me down. Slow builds all over the place in many of my app projects, and my PC is blazing fast - it shouldn't all be that slow, even if you're running Eclipse!

Working on DSLR Controller has been driving me mad - testing a minor change in the underlying communications library, then building and launching the app - ugh! So I set out to fix this. I had done all the usual tricks, even gave Eclipse loads more memory (helped with regular performance, but not building) but nothing major seemed to change. Then I figured out most of the time building was spent in AAPT. So I synced my AOSP repo (2012.09.26, took a few minutes), tried to get the Windows SDK to build on my Linux b

 

ox (took several hours) and finally got to actually mucking with the source.

Found the bottleneck (for my long-build-time projects at least, related to XML file compilation) and fixed it (by introducing a simple cache). "DLSR Controller" build time has gone down from 35 seconds minimum, to 2-3 seconds ( >10 times faster). Hell, I can even turn "Build Automatically" back on without getting constant delays!

Note that my build times quoted only apply to incremental internal builds. If your images still need to be "crushed" (optimized), or you're "exporting" an APK (final build for publication), build time will still be significantly longer. However, during normal development and testing (by far most builds if you're making an app in Eclipse) those stages are not performed, and builds should be lightning fast.

"Fixed" is a big word though, right now it's more of a "hack", and it needs some pollish, so the patch can be submitted to AOSP. I don't want to keep it from you for that long, so my first test build is attached - don't use it in production builds..

Patch code has been submitted to:
AOSP - #1 Cancelled, #2 Review in Progress ... superseded by ctate rewrite
AOKP - #1 Merged, #2 Merged
CM - #1 Cancelled, #2 Merged

Attached ZIP includes Linux, Windows and Mac OS X versions.

The files are drop-in replacement, but I would certainly advise you to backup the originals for your production builds! Also, don't forget to chmod/chown on Linux or it won't work.

Enjoy and leave some feedback

Will this help your project build ?

A quick way to spot if this will have effect on your slow build is as follows:

- In Eclipse, set Build output to Verbose under Window -> Preferences -> Android -> Build.
- Clean and build your project.
- If the build pauses on lines in the "(new resource id <filename> from <filename>)" format, you have the problem FAAPT fixes

(of course, you can also run aapt manually if you know how, you'll get the same output)

In a full framework build the optimizations only affect a very small portion of the actions done during the build, so you won't see any spectaculair speed increases there.

Update (#2)

I have updated the patch code to fix problems with Mac OS X compatibility, I've also included a Mac OS X binary in the new zip file.

 

http://log.hanjava.net/post/32862213063/fast-aapt-android

 

이 친구는 DSLR Controller라는 프로젝트를 진행하는데 자신의 PC 성능이 고사양인데도 불구하고 Android 빌드 시간이 너무 오래 걸림에 분을 삭히지 못하고 원인파악에 돌입함.

원인은 AAPT(Android Asset Packaging Tool)의 XML compilation time이 너무 오래걸림을 파악하고 변경된 XML만 처리하도록 caching을 추가.

이 친구는 35초 걸리던 빌드가 2~3초로 줄었다는데 과장은 살짝 섞인듯(분명 남자인듯)

사용법은 간단. zip파일을 다운로드하면 Windows, Linux, Mac용 aapt가 있는데 이를 Android SDK/platform-tools 아래의 aapt와 교체하면 끝.

테스트 결과 eclipse에서는 빨라지는데 android-maven-plugin에서는 별 도움이 안됨. 왜 인지는 모르겠음

 

 

아래 파일은 링크 오류시를 받기위해 올려 놓음 아래에서 받지 마시고 링크에서 받으세요  

 

aapt-2.zip

프로그램/Android 2013. 3. 12. 00:02

안드로이드 엑티비티 투명 , android activity Dim

public popup_away(Context context) {
super(context, android.R.style.Theme_Translucent_NoTitleBar);
// TODO Auto-generated constructor stub
cont = context;
 
}
 
///또하나
final Dialog dialog = new Dialog(this, R.style.Theme_Dialog);


///아래는 XML로 하는것

프로그램/Android 2013. 3. 11. 23:59

안드로이드 Intent 사용법

// 웹페이지 띄우기 
Uri uri = Uri.parse("http://www.google.com"); 
Intent it  = new Intent(Intent.ACTION_VIEW,uri); 
startActivity(it); 

// 구글맵 띄우기 
Uri uri = Uri.parse("geo:38.899533,-77.036476"); 
Intent it = new Intent(Intent.Action_VIEW,uri); 
startActivity(it);  

// 구글 길찾기 띄우기 
Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=출발지주소&daddr=도착지주소&hl=ko"); 
Intent it = new Intent(Intent.ACTION_VIEW,URI); 
startActivity(it); 

// 전화 걸기 
Uri uri = Uri.parse("tel:xxxxxx"); 
Intent it = new Intent(Intent.ACTION_DIAL, uri);   
startActivity(it);   
Uri uri = Uri.parse("tel.xxxxxx"); 
Intent it = new Intent(Intent.ACTION_CALL,uri); 

// 퍼미션을 잊지 마세요.  
// SMS/MMS 발송 
Intent it = new Intent(Intent.ACTION_VIEW);    
it.putExtra("sms_body", "The SMS text");    
it.setType("vnd.android-dir/mms-sms");    
startActivity(it);   

// SMS 발송 
Uri uri = Uri.parse("smsto:0800000123");    
Intent it = new Intent(Intent.ACTION_SENDTO, uri);    
it.putExtra("sms_body", "The SMS text");    
startActivity(it);   

// MMS 발송 
Uri uri = Uri.parse("content://media/external/images/media/23");    
Intent it = new Intent(Intent.ACTION_SEND);    
it.putExtra("sms_body", "some text");    
it.putExtra(Intent.EXTRA_STREAM, uri);    
it.setType("image/png");    
startActivity(it);  

// 이메일 발송 
Uri uri = Uri.parse("mailto:xxx@abc.com"); 
Intent it = new Intent(Intent.ACTION_SENDTO, uri); 
startActivity(it); 
Intent it = new Intent(Intent.ACTION_SEND);    
it.putExtra(Intent.EXTRA_EMAIL, "me@abc.com");    
it.putExtra(Intent.EXTRA_TEXT, "The email body text");    
it.setType("text/plain");    
startActivity(Intent.createChooser(it, "Choose Email Client"));   
Intent it = new Intent(Intent.ACTION_SEND);      
String[] tos = {"me@abc.com"};      
String[] ccs = {"you@abc.com"};      
it.putExtra(Intent.EXTRA_EMAIL, tos);      
it.putExtra(Intent.EXTRA_CC, ccs);      
it.putExtra(Intent.EXTRA_TEXT, "The email body text");      
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");      
it.setType("message/rfc822");      
startActivity(Intent.createChooser(it, "Choose Email Client"));   
 
// extra 추가하기 
Intent it = new Intent(Intent.ACTION_SEND);    
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");    
it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");    
sendIntent.setType("audio/mp3");    
startActivity(Intent.createChooser(it, "Choose Email Client")); 

// 미디어파일 플레이 하기 
Intent it = new Intent(Intent.ACTION_VIEW); 
Uri uri = Uri.parse("file:///sdcard/song.mp3"); 
it.setDataAndType(uri, "audio/mp3"); 
startActivity(it); 
Uri uri = Uri.withAppendedPath( 
  MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");    
Intent it = new Intent(Intent.ACTION_VIEW, uri);    
startActivity(it);   

// 설치 어플 제거 
Uri uri = Uri.fromParts("package", strPackageName, null);    
Intent it = new Intent(Intent.ACTION_DELETE, uri);    
startActivity(it); 

// APK파일을 통해 제거하기 
Uri uninstallUri = Uri.fromParts("package", "xxx", null); 
returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri); 

// APK파일 설치 
Uri installUri = Uri.fromParts("package", "xxx", null); 
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri); 

// 음악 파일 재생 
Uri playUri = Uri.parse("file:///sdcard/download/everything.mp3"); 
returnIt = new Intent(Intent.ACTION_VIEW, playUri); 

// 첨부파일을 추가하여 메일 보내기 
Intent it = new Intent(Intent.ACTION_SEND);   
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");   
it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/eoe.mp3");   
sendIntent.setType("audio/mp3");   
startActivity(Intent.createChooser(it, "Choose Email Client")); 

// 마켓에서 어플리케이션 검색 
Uri uri = Uri.parse("market://search?q=pname:pkg_name");   
Intent it = new Intent(Intent.ACTION_VIEW, uri);   
startActivity(it);   

// 패키지명은 어플리케이션의 전체 패키지명을 입력해야 합니다. 
// 마켓 어플리케이션 상세 화면 
Uri uri = Uri.parse("market://details?id=어플리케이션아이디");   
Intent it = new Intent(Intent.ACTION_VIEW, uri);   
startActivity(it); 

// 아이디의 경우 마켓 퍼블리싱사이트의 어플을 선택후에 URL을 확인해보면 알 수 있습니다. 
// 구글 검색 
Intent intent = new Intent(); 
intent.setAction(Intent.ACTION_WEB_SEARCH); 
intent.putExtra(SearchManager.QUERY,"searchString") 
startActivity(intent);