노무현 전 대통령 서거 추모글 남기기

ArrayList 의 구조를 가지고 있는 배열을 쓰기..


검색해보니까 ArrayList 를 배열로 바꾸는 것만 잔뜩있고 아니면 ArrayList<Stri ng[]> 이런 구조 얘기만 있고해서 헤메고 있었다..


그러다 얻게 된 해결책


https://stackoverflow.com/questions/7131652/generic-array-creation-error/23034391


링크에 좋아요 엄청받은 것을 적용해 보았더니 안된다..


두번째


First, let

public static ArrayList<myObject>[] a = new ArrayList[2];

Then initialize

for(int i = 0; i < a.length; i++) {
     a[i] = new ArrayList<myObject>();
}

이렇게 하니까 잘된다.


세번째는 선언하는 방식만 변경이 있을 뿐 초기화는 어짜피 따로 해줘야 동작하더라..


public static ArrayList<myObject>[] a = (ArrayList<myObject>[])new ArrayList<?>[2];
public static ArrayList<myObject>[] a = (ArrayList<myObject>[])new ArrayList[2];


Posted by Kelly Cook
,

어플 개발중에 다른 어플과 연동을할 일이 있어서 sendBroadcast(intent)를 해서 사용하는데


가끔 실행을 해도 먹어 버리고 실행이 안된다.


그전에 비슷한 경우가 있었는데 이번 경우는 BroadcastQueue: Background execution not allowed: receiving Intent{


어쩌구 저쩌구라고 로그가 찍힌다.


대충 찾아보면 Android 8.0 Oreo에서 배터리 절약을 위해 암시적 Broadcast가 제한이 있다는거 같다.


근데 주고 받을 앱이 8.0이 아니면 문제 없다는거 같은데 OS가 8.0인 폰에서 해도 나오는 듯하다.


구글링을 해봤는데 제한이 있을거다 이런 얘기만 있고 해결책이 없다.


리시버를 받는 곳에 퍼미션을 지정해서 부르는 곳에 같이 넣어준다면 된다는 얘기가 있는데 받는 곳은 일단 내가 바꿀 수가 없어서 패쓰..


더 찾아보다가

private void sendImplicitBroadcast(Context ctxt, Intent i) 

PackageManager pm=ctxt.getPackageManager(); 

List<ResolveInfo> matches=pm.queryBroadcastReceivers(i, 0);

for (ResolveInfo resolveInfo : matches) {

Intent explicit=new Intent(i);

ComponentName cn= new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName, resolveInfo.activityInfo.name);

explicit.setComponent(cn);

ctxt.sendBroadcast(explicit);

}

}

이런게 있어서 적용해 봤는데 일단 된다.


일단 적용해보고 해결이 됐으면 좋겠네..

Posted by Kelly Cook
,

동영상 녹화를 해봤다..


public void RecordVideo(string path)
    {
        mRecorder = new MediaRecorder();
        mRecorder.SetAudioSource(AudioSource.Mic);
        mRecorder.SetVideoSource(VideoSource.Camera);
        mRecorder.SetOutputFormat(OutputFormat.MPEG_4);
        mRecorder.SetAudioEncoder(AudioEncoder.AMR_NB);
        mRecorder.SetVideoEncoder(VideoEncoder.H264);
        mRecorder.SetProfile(CamcorderProfile.Get(CamcorderProfile.QUALITY_HIGH)));
mRecorder.SetOutputFile(path); mRecorder.SetMaxDuration (10000); mRecorder.Prepare(); try{ mRecorder.Start(); }catch( Exception ex) { ex.GetType (); } }

이런 식으로하면 에러가 난다..(Illegal State Exception)


mRecorder.SetProfile(CamcorderProfile.Get(CamcorderProfile.QUALITY_HIGH));

기본이 Low인가?? 해서 넣어봐도 에러가 난다..

mRecorder.SetProfile(CamcorderProfile.Get(CamcorderProfile.QUALITY_LOW));
mRecorder.SetProfile(CamcorderProfile.get(Camera.CameraInfo.CAMERA_FACING_FRONT, CamcorderProfile.QUALITY_LOW));

이부분에서 에러가 나기에 주석 처리해주면 동작한다..



그러나.. 화질이 엉망징창이다..


깍두기 형님들이 무더기로 인사한다.


저부분이 안돼니 이거라도 이것 저것 바꿔보자..

        mRecorder.SetOutputFormat(OutputFormat.MPEG_4);
        mRecorder.SetAudioEncoder(AudioEncoder.AMR_NB);
        mRecorder.SetVideoEncoder(VideoEncoder.H264);

그래봐야 별반 다를게 없다..


이것 저것 만지다보니 화질이 좋아졌다..


        //mRecorder.SetOutputFormat(OutputFormat.MPEG_4);
        //mRecorder.SetAudioEncoder(AudioEncoder.AMR_NB);
        //mRecorder.SetVideoEncoder(VideoEncoder.H264);
        mRecorder.SetProfile(CamcorderProfile.Get(CamcorderProfile.QUALITY_HIGH)));

주석으로 없애니 잘 동작한다.


CamcorderProfile.QUALITY_HIGH은 테스트 폰에서 1920* 1080 이였다..
mRecorder.SetProfile(CamcorderProfile.Get(CamcorderProfile.QUALITY_720P)));

결국 720p로 낙점..


mediaRecorder.setProfile 과 기타등등(mediaRecorder.setOutputFormat)은 같이쓰면 에러가 난다..

이유는 잘 모르겠다..


Format, Encoder로 화질을 좋게 할수는 없는 것인가??


화질이 너무구려 책보며 OpenGl을 끄적일까 했는데 일단은 여기까지..



Posted by Kelly Cook
,
adb shell "run-as 패.키.지.명 cat databases/db 파일명 > /sdcard0/Android/data/db 파일명"


안드로이드 디바이스에서 DB 파일 접근 방법 (Access sqlite database on android device)


Posted by Kelly Cook
,

다른 액티비티로 처리를 떠넘길 때 

intent = new Intent(mContext, Depth2Activity.class);

intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); // setResult의 처리를 다음 액티비티에게 미룬다.

intent.putExtra("className", ExerciseDetailAddLayout.class.getSimpleName());

intent.putExtra("exerciseDate", exerciseDate);

Depth1Activity.mActivity.startActivity(intent);




떠넘겨 받은 액티비티에서 결과를 전달해줄 때 

// 성공

activity.setResult(Activity.RESULT_OK);

activity.finish(); // 반드시 여기! - 그래야지만 MainActivity에서 RESULT_OK로 떨어진다.

Intent intent = new Intent(mContext, MainActivity.class);

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

activity.startActivity(intent);

MainApplication.slideRightToLeftShow(activity);

Posted by Kelly Cook
,