Java Code Examples for android.util.Log.d()

The following are Jave code examples for showing how to use d() of the android.util.Log class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: grid-video-viewer   File: DecodeThread.java   View Source Code Vote up 7 votes
private MediaFormat selectTrack(MediaExtractor extractor) {
    int trackCount = extractor.getTrackCount();
    Log.d(TAG, "trackCount :" + trackCount);

    MediaFormat format;
    for (int i = 0; i < trackCount; i++) {
        extractor.selectTrack(i);
        format = extractor.getTrackFormat(i);
        Log.d(TAG, "Track media format :" + format.toString());

        String mime = format.getString(MediaFormat.KEY_MIME);
        if (mime.startsWith("video/")) {
            return format;
        }
    }

    return null;
}
 
Example 2
Project: Calendouer   File: MainActivity.java   View Source Code Vote up 6 votes
private void getWeather() {
    Log.d("weather", "getWeather");
    weatherHolder.setVisibility(View.VISIBLE);

    String lat = sharedPref.getString("Latitude", "");
    String lng = sharedPref.getString("Longitude", "");

    if (!lat.equals("") && !lng.equals("")) {
        String apiStr = "https://api.thinkpage.cn/v3/weather/daily.json?key=txyws41isbyqnma5&" +
                "location=" + lat + ":" + lng + "&language=zh-Hans&unit=c";
        getWeatherTask = new GetWeather().execute(apiStr);
        Log.d("weather", "Location already know");
    } else {
        Log.d("weather", "startLocation");
        mLocationClient.startLocation();
    }
}
 
Example 3
Project: cat-is-a-dog   File: AddHabitEventActivity.java   View Source Code Vote up 6 votes
/**
 * Handler when menu item is selected
 * @param item
 * @return
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Log.d(TAG, "item:" + item.getItemId());
    switch (item.getItemId()) {
        // Respond to the action bar's Up/Home button
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;
        case SAVE_BUTTON_ID:
            saveEvent();
            Toast.makeText(this, "Habit event saved!", Toast.LENGTH_SHORT).show();
            NavUtils.navigateUpFromSameTask(this);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 4
Project: robo-car   File: LcdDisplay.java   View Source Code Vote up 6 votes
/**
 * Write text to the display.
 *
 * @param text text to write. Make sure that max line length is 16 and you provide maximum 2 lines.
 */
@Override
public void write(@NonNull String text) {
    try {

        Log.d(TAG, "write: Printing - " + text);
        mLcd.clear();

        //Split by new lines.
        String[] lines = text.split("\n");
        if (lines.length > 2) throw new RuntimeException("Cannot print more than 2 lines.");

        //Print the line 1
        for (String line : lines) {
            mLcd.print(line);
            //Move the cursor to line 2
            mLcd.setCursor(0, 1);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 5
Project: VirtualAPK   File: SecondActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    findViewById(R.id.button1).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(SecondActivity.this, ThirdActivity.class);
            intent.putExtra("time", System.currentTimeMillis());
            startActivity(intent);
        }
    });
    Log.d(TAG, "onCreate");
}
 
Example 6
Project: AndroidWeb   File: ReflectTest.java   View Source Code Vote up 6 votes
@Test
public void test_0_reflect() {
    Class<TestController> testController = TestController.class;

    Controller con = testController.getAnnotation(Controller.class);
    Log.d("gws:", con.value());
    Field[] fields = testController.getFields();
    for (Field field : fields) {
        Log.i("yyd", "field.getName()--->" + field.getName());
    }

    try {
        Class[] classes = new Class[]{int.class, String.class};
        Method method = testController.getMethod("testJson", classes);//若有参数,则参数类的填写是必须的,不然会找不到
        RequestMapping requestMapping = method.getAnnotation(RequestMapping.class);
        Log.d("gws:", requestMapping.value().toString());
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }

}
 
Example 7
Project: Ships   File: NmeaClientService.java   View Source Code Vote up 6 votes
private DatagramSocketConfig createRepeaterConfig(){
    final String tag="createRepeaterConfig - ";
    DatagramSocketConfig result=null;

    final String repeatHost = SettingsUtils.getInstance().parseFromPreferencesAisMessagesDestinationHost();
    final int repeatPort = SettingsUtils.getInstance().parseFromPreferencesAisMessagesDestinationPort();

    String informText="Not repeating NMEA messages.";
    if (repeatHost!=null && !(repeatHost.equals(NMEA_UDP_HOST) && repeatPort==NMEA_UDP_PORT)) {
        result = new DatagramSocketConfig(repeatHost,repeatPort);
        if (validateDatagramSocketConfig(result)) {
            informText="Repeating NMEA messages to UDP: " + result;
Toast.makeText(this,informText,Toast.LENGTH_LONG).show();
            Analytics.getInstance().logEvent(TAG,"NMEA Repeater","repeatHost: "+repeatHost+", repeatPort: "+repeatPort);
        } else {
            result=null;
        }
    } else {
        informText="IGNORE NMEA repeat setting: Asked to repeat to build in address:port or invalid settings.";
    }

    Log.d(TAG,tag+informText);

    return result;
}
 
Example 8
Project: grafika   File: CameraCaptureActivity.java   View Source Code Vote up 6 votes
@Override  // runs on UI thread
public void handleMessage(Message inputMessage) {
    int what = inputMessage.what;
    Log.d(TAG, "CameraHandler [" + this + "]: what=" + what);

    CameraCaptureActivity activity = mWeakActivity.get();
    if (activity == null) {
        Log.w(TAG, "CameraHandler.handleMessage: activity is null");
        return;
    }

    switch (what) {
        case MSG_SET_SURFACE_TEXTURE:
            activity.handleSetSurfaceTexture((SurfaceTexture) inputMessage.obj);
            break;
        default:
            throw new RuntimeException("unknown msg " + what);
    }
}
 
Example 9
Project: KUtils-master   File: JsonLog.java   View Source Code Vote up 5 votes
public static void printJson(int type, String tag, String msg, String headString) {

        String message;

        try {
            if (msg.startsWith("{")) {
                JSONObject jsonObject = new JSONObject(msg);
                message = jsonObject.toString(KLog.JSON_INDENT);
            } else if (msg.startsWith("[")) {
                JSONArray jsonArray = new JSONArray(msg);
                message = jsonArray.toString(KLog.JSON_INDENT);
            } else {
                message = msg;
            }
        } catch (JSONException e) {
            message = msg;
        }

        KLogUtil.printLine(type, tag, true);
        message = headString + KLog.LINE_SEPARATOR + message;
        String[] lines = message.split(KLog.LINE_SEPARATOR);
        for (String line : lines) {
            switch (type) {
                case D:
                    Log.d(tag, "║ " + line);
                    break;
                case E:
                    Log.e(tag, "║ " + line);
                    break;
                case W:
                    Log.w(tag, "║ " + line);
                    break;
                case I:
                    Log.i(tag, "║ " + line);
                    break;
            }
        }
        KLogUtil.printLine(type, tag, false);
    }
 
Example 10
Project: pjsip-android   File: PjCamera.java   View Source Code Vote up 5 votes
public void surfaceCreated(SurfaceHolder holder)
   {
Log.d(TAG, "VideoCaptureAndroid::surfaceCreated");
try {
    if(camera != null) {
	camera.setPreviewDisplay(holder);
    }
} catch (IOException e) {
    Log.e(TAG, "Failed to set preview surface!", e);
}
   }
 
Example 11
Project: microbit   File: GoogleAnalyticsManager.java   View Source Code Vote up 5 votes
public void sendConnectStats(final String screenName, final Constants.ConnectionState connectionState, final String firmware, final String duration) {
    try {
        if (mShareStatistic) {
            HashMap<Integer, String> eventLabels = new HashMap<>();
            Log.d(TAG, "sendConnectStats, firmware " + firmware + " duration " + duration + " connectionState " + connectionState);

            eventLabels.put(FIRMWARE, TextUtils.isEmpty(firmware) ? "-" : firmware);
            eventLabels.put(DURATION, TextUtils.isEmpty(duration) ? "-" : duration );
            switch (connectionState) {
                case SUCCESS:
                    Log.d(TAG, "Sending Connection stats - MSG(SUCCESS) - Firmware = " + firmware);
                    eventLabels.put(CONNECT_STATUS, "success");
                    break;
                case FAIL:
                    Log.d(TAG, "Sending Connection stats - MSG(Failed)");
                    eventLabels.put(CONNECT_STATUS, "fail");

                    break;
                case DISCONNECT:
                    Log.d(TAG, "Sending Connection stats - MSG(DISCONNECT) - Firmware = " + firmware + " Duration =" + duration);
                    eventLabels.put(CONNECT_STATUS, "disconnect");
                    break;
                default:
                    break;
            }

            sendEvent(screenName, "Connection", "Connect", eventLabels);
        } else {
            Log.d(TAG, "Sharing of stats is disabled by user");
        }
    } catch (RuntimeException e) {
        Log.e(TAG, "Sending stats exception " + e.getMessage());
    }
}
 
Example 12
Project: react-native-twitterkit   File: TweetView.java   View Source Code Vote up 5 votes
private void updateSize() {
  LogUtils.d(TAG, "updateSize");

  if (getWidth() <= 0) {
    Log.d(TAG, "width is still 0, postponing updateSize()");
    postponedResize = true;
    return;
  }

  measureTweet();
  requestLayout();


  fireSizeChange(getWidth(), tweetView.getMeasuredHeight());
}
 
Example 13
Project: CustomAndroidOneSheeld   File: PullToRefreshBase.java   View Source Code Vote up 5 votes
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
	if (DEBUG) {
		Log.d(LOG_TAG, "addView: " + child.getClass().getSimpleName());
	}

	final T refreshableView = getRefreshableView();

	if (refreshableView instanceof ViewGroup) {
		((ViewGroup) refreshableView).addView(child, index, params);
	} else {
		throw new UnsupportedOperationException("Refreshable View is not a ViewGroup so can't addView");
	}
}
 
Example 14
Project: Blockly   File: LuaActivity.java   View Source Code Vote up 5 votes
/**
 * 用于更新XML文件的网络请求
 */
public void andrUpdate(String returnedFileName,String returnedFileId){
    RequestQueue requestQueue = MyApplication.getRequestQueue();
    sharedPreferences = MyApplication.getSharedPreferences();
    userId = sharedPreferences.getString("email","");
    token = sharedPreferences.getString("token","");
    JSONObject jsonObject = new JSONObject();
    String fileName = dialogMsg+"_"+getWorkspaceSavePath();
    try{
        jsonObject.put("fileName",returnedFileName);
        jsonObject.put("fileString",AbstractBlocklyActivity.xmltostring);//AbstractBlocklyActivity.xmltostring
        jsonObject.put("fileId",returnedFileId);//这里应该通过一个方法来判断id的值,先暂时写成这样
        jsonObject.put("userId",userId);
        jsonObject.put("token",token);

    }catch (JSONException e){
        e.printStackTrace();
    }
    Log.d("AndrUpdate_JsonObj",jsonObject.toString());

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url_upload, jsonObject, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            uploadReceive uploadReceive = new uploadReceive();
            uploadReceive.setStatus(response.optString("status"));
            uploadReceive.setErrMsg(response.optString("errMsg"));
            Log.d("AndrUpdate_Response",response.toString());

            judge_upload(uploadReceive.getStatus(),uploadReceive.getErrMsg());
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("AndrUpdate_Error",error.toString(),error);
        }
    });

    requestQueue.add(jsonObjectRequest);

}
 
Example 15
Project: godot-google-play-game-services   File: GodotPlayGameServices.java   View Source Code Vote up 5 votes
private void debugLog(String message) {
    if (debug) Log.d(TAG, MODULE + ": " + message);
}
 
Example 16
Project: aos-Video   File: VideoInfoScraperSearchFragment.java   View Source Code Vote up 5 votes
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	if(DBG) Log.d(TAG, "onCreate this="+this+"  savedInstanceState="+savedInstanceState);
    setInfo((Video) getActivity().getIntent().getExtras().get(VideoInfoScraperActivity.EXTRA_VIDEO));
    setRetainInstance(false); // keep fragment instance when rotating screen
}
 
Example 17
Project: AppTycoon   File: UiUpdateHandler.java   View Source Code Vote up 5 votes
@Override
public void handleMessage(Message msg) {
    //Log.d(TAG, "handleMessage() - what  = " + msg.what);

    if (!mUpdaters.containsKey(msg.what)) {
        Log.d(TAG, "handleMessage() - no UiUpdater assigned -> do nothing");
        return;
    }

    for (UiUpdater updater : mUpdaters.get(msg.what)) {
        updater.updateUi(msg.what, msg.getData());
    }

}
 
Example 18
Project: androidthings-imageclassifier   File: CameraHandler.java   View Source Code Vote up 5 votes
/**
 * Initialize the camera device
 */
public void initializeCamera(Context context,
                             Handler backgroundHandler,
                             ImageReader.OnImageAvailableListener imageAvailableListener) {
    // Discover the camera instance
    CameraManager manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
    String[] camIds = {};
    try {
        camIds = manager.getCameraIdList();
    } catch (CameraAccessException e) {
        Log.d(TAG, "Cam access exception getting IDs", e);
    }
    if (camIds.length < 1) {
        Log.d(TAG, "No cameras found");
        return;
    }
    String id = camIds[0];
    Log.d(TAG, "Using camera id " + id);
    // Initialize the image processor
    mImageReader = ImageReader.newInstance(IMAGE_WIDTH, IMAGE_HEIGHT,
            ImageFormat.JPEG, MAX_IMAGES);
    mImageReader.setOnImageAvailableListener(
            imageAvailableListener, backgroundHandler);
    // Open the camera resource
    try {
        manager.openCamera(id, mStateCallback, backgroundHandler);
    } catch (CameraAccessException cae) {
        Log.d(TAG, "Camera access exception", cae);
    }
}
 
Example 19
Project: fefereader   File: UpdateService.java   View Source Code Vote up 4 votes
/**
 * Start update in a separate thread (if not already running).
 */
private void performUpdate() {
    // Check whether update is running
    if(updateThread != null) {
        Log.e(TAG, "Ignoring update request due to running update");
        Intent skippedIntent = new Intent(BROADCAST_UPDATE_SKIPPED);
        sendOrderedBroadcast(skippedIntent, null);
        return;
    }

    updateThread = new Thread(new Runnable() {
        @Override
        public void run() {
            boolean success = false;

            try {
                OkHttpClient client = new OkHttpClient.Builder()
                    .addNetworkInterceptor(new StethoInterceptor())
                    .build();
                Parser parser = new Parser();
                Fetcher fetcher = new Fetcher(client, parser);
                List<RawPost> posts = fetcher.fetch();

                for(RawPost post : posts) {
                    databaseWrapper.addOrUpdatePost(post);
                }

                success = true;
                Log.d(TAG, "Update finished");
            }
            catch(ParseException | IOException e) {
                e.printStackTrace();
            }
            finally {
                Intent finishedIntent = new Intent(BROADCAST_UPDATE_FINISHED);
                finishedIntent.putExtra(EXTRA_UPDATE_SUCCESS, success);
                sendOrderedBroadcast(finishedIntent, null);

                updateThread = null;
            }
        }
    });
    updateThread.start();
}
 
Example 20
Project: keepass2android   File: FragmentFiles.java   View Source Code Vote up 4 votes
/**
 * Updates or inserts {@code path} into history database.
 */
private void updateDbHistory(Uri path) {
    if (BuildConfig.DEBUG)
        Log.d(CLASSNAME, "updateDbHistory() >> path = " + path);

    Calendar cal = Calendar.getInstance();
    final long beginTodayMillis = cal.getTimeInMillis()
            - (cal.get(Calendar.HOUR_OF_DAY) * 60 * 60 * 1000
                    + cal.get(Calendar.MINUTE) * 60 * 1000 + cal
                    .get(Calendar.SECOND) * 1000);
    if (BuildConfig.DEBUG) {
        Log.d(CLASSNAME,
                String.format("beginToday = %s (%s)", DbUtils
                        .formatNumber(beginTodayMillis), new Date(
                        beginTodayMillis)));
        Log.d(CLASSNAME, String.format("endToday = %s (%s)", DbUtils
                .formatNumber(beginTodayMillis + DateUtils.DAY_IN_MILLIS),
                new Date(beginTodayMillis + DateUtils.DAY_IN_MILLIS)));
    }

    /*
     * Does the update and returns the number of rows updated.
     */
    long time = new Date().getTime();
    ContentValues values = new ContentValues();
    values.put(HistoryContract.COLUMN_PROVIDER_ID,
            BaseFileProviderUtils.getProviderId(path.getAuthority()));
    values.put(HistoryContract.COLUMN_FILE_TYPE,
            BaseFile.FILE_TYPE_DIRECTORY);
    values.put(HistoryContract.COLUMN_URI, path.toString());
    values.put(HistoryContract.COLUMN_MODIFICATION_TIME,
            DbUtils.formatNumber(time));

    int count = getActivity()
            .getContentResolver()
            .update(HistoryContract.genContentUri(getActivity()),
                    values,
                    String.format(
                            "%s >= '%s' and %s < '%s' and %s = %s and %s like %s",
                            HistoryContract.COLUMN_MODIFICATION_TIME,
                            DbUtils.formatNumber(beginTodayMillis),
                            HistoryContract.COLUMN_MODIFICATION_TIME,
                            DbUtils.formatNumber(beginTodayMillis
                                    + DateUtils.DAY_IN_MILLIS),
                            HistoryContract.COLUMN_PROVIDER_ID,
                            DatabaseUtils.sqlEscapeString(values
                                    .getAsString(HistoryContract.COLUMN_PROVIDER_ID)),
                            HistoryContract.COLUMN_URI,
                            DatabaseUtils.sqlEscapeString(values
                                    .getAsString(HistoryContract.COLUMN_URI))),
                    null);
    if (count <= 0) {
        values.put(HistoryContract.COLUMN_CREATE_TIME,
                DbUtils.formatNumber(time));
        getActivity().getContentResolver().insert(
                HistoryContract.genContentUri(getActivity()), values);
    }
}