https://stackoverflow.com/questions/46988102/errorcom-android-tools-aapt2-aapt2exception-aapt2-error-check-logs-for-detail


Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

Error:Execution failed for task ':app:processDebugResources'.

> Failed to execute aapt



해결

gradle.properties 열기

android.enableAapt2=false

복붙 -> Sync Now

testDialog = new AlertDialog.Builder(mContext) 

 .setCustomTitle(title_tv) .

 setMessage("1번 : 원격제어\n2번 : 센서 모니터링") 

 .create();

testDialog.show(); 


TextView msg_tv = (TextView)speechDialog.findViewById(android.R.id.message);

msg_tv.setTextSize(15);

msg_tv.setBackgroundColor(Color.WHITE);

구글 API 이용하여 원하는 주소값의 위도,경도 받아오기


google 프로젝트 등록 필요.

https://developers.google.com/maps/documentation/geocoding/get-api-key?hl=ko


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
 
public class Geocode {
    
    String response = "";
    
    String run(String address) throws IOException {
        HttpPost httpPost = new HttpPost("https://maps.googleapis.com/maps/api/geocode/json?address="+address+"&components=country:KR");
        
        HttpClient httpclient = new DefaultHttpClient();
        
        HttpResponse httpResponse = httpclient.execute(httpPost);
        
        response = EntityUtils.toString(httpResponse.getEntity());
        
        return response;
    }
}
 
cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.io.IOException;
 
import org.apache.http.ParseException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
 
public class GeoThread extends Thread{
 
    Handler handler;
    boolean isRun = true;
    String address = "";
 
    public GeoThread(Handler handler){
        this.handler = handler;
    }
 
    public void run(){
        Geocode geo = new Geocode();
        Bundle bun = new Bundle();
            String response;
            try {
                response = geo.run(address);
                JSONObject json = new JSONObject(response);
                
                JSONArray results = (JSONArray) json.get("results");
                
                
                JSONObject resultsArray = (JSONObject) results.get(0);
 
                JSONObject jsonObject = (JSONObject) resultsArray.get("geometry");
                
                JSONObject jsonObject2 = (JSONObject) jsonObject.get("location");
 
 
                double address_lat = (double) jsonObject2.get("lat");
                double address_lng = (double) jsonObject2.get("lng");
                
 
                bun.putDouble("address_lat", address_lat);
                bun.putDouble("address_lng", address_lng);
                
                Message msg = handler.obtainMessage();
                msg.setData(bun);
                handler.sendMessage(msg);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
 
    }
 
}
cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
    원하는 Activity에서
 
                GeoThread geo = new GeoThread(addressHandler);
                
                String address = address_edt.getText().toString();
                address = address.replaceAll(" """);
                //주소에 
                geo.address = address;
                geo.start();
 
 
    Handler addressHandler = new Handler() {
        public void handleMessage(Message msg) {
            Bundle bun = msg.getData();
            
            double lat = bun.getDouble("address_lat");
            double lng = bun.getDouble("address_lng");
            
 
        }
    };
    
cs


AndroidManifest.xml

1
2
3
4
5
6
7
8
9
10
        <service android:name=".MyFcmListenerService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <service android:name=".MyInstanceIDListenerService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>
cs

MyFcmListenerService.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
public class MyFcmListenerService extends FirebaseMessagingService {
 
    @Override
    public void onMessageReceived(RemoteMessage message) {
        Map<StringString> data = message.getData();
 
        String time = data.get("time");
        String msg = data.get("message");
 
        sendPushNotification(time, msg);
    }
 
    private void sendPushNotification(String title, String message) {
        Intent intent = new Intent(this, LoginActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this0 /* Request code */, intent,
                PendingIntent.FLAG_ONE_SHOT);
 
        long[] pattern = {200100500300};
 
 
        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.icon)
                .setContentTitle(title)
                .setContentText(message)
                .setAutoCancel(true)
                .setVibrate(pattern)
                .setSound(defaultSoundUri)
                .setLights(0000002555002000)
                .setContentIntent(pendingIntent);
 
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
 
        PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock wakelock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
        wakelock.acquire(5000);
 
        notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
    }
}
cs

MyInstanceIDListenerService.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class MyInstanceIDListenerService extends FirebaseInstanceIdService {
 
    @Override
    public void onTokenRefresh() {
        // Get updated InstanceID token.
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Log.d(TAG, "Refreshed token: " + refreshedToken);
 
        // If you want to send messages to this application instance or
        // manage this apps subscriptions on the server side, send the
        // Instance ID token to your app server.
        sendRegistrationToServer(refreshedToken);
 
    }
 
 
    private void sendRegistrationToServer(String refreshedToken) {
    }
 
 
}
cs


1
2
3
android:nextFocusDown="@id/원하는 포커스"
 
android:imeOptions="actionDone"  //다음 없이 완료 //
cs


'이것저것 > 자바*안드로이드' 카테고리의 다른 글

JAVA Google Geocoding API  (0) 2017.02.20
FCM  (0) 2017.02.03
안드로이드 scrollview 스크롤바 보이기  (0) 2017.01.23
안드로이드 xml 에서 inputType  (0) 2017.01.19
자바 내일날짜 구하기  (0) 2017.01.18
1
2
3
android:scrollbarFadeDuration = "0"
 
android:scrollbarAlwaysDrawVerticalTrack = "True"
cs
1
2
3
android:scrollbarThumbVertical="원하는 컬러" //현위치 스크롤바 색깔
android:scrollbarTrackVertical="원하는 컬러" //전체 스크롤바 색깔
android:scrollbarSize="2dp" // 스크롤바 두께 설정
cs


@color/컬러이름...

color.xml


1
2
3
4
5
6
7
XML 소스
 
android:inputType="" 
 
number 양수 
numberSigned 양수,음수 
numberDecimal 양수 소수점 
cs


1
2
3
4
5
6
7
8
9
10
Calendar cal = new GregorianCalendar();
cal.add(Calendar.DATE, i);
 
// int i
// 0 == 오늘
// 1 == 내일
//-1 == 어제
 
 
Date date = cal.getTime();
cs


안드로이드 매니패스트의 application부분에 android:largeHeap="true" 

 

 

과도한 thread연산 시 heap메모리 부족.. 다른 근본적 해결방법 요구됨.

AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT : 사일런트 모드일 경우
audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE : 진동모드일 경우
audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL : 벨 모드일 경우
audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);  //
audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); //진동
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); //무음


+ Recent posts