当前位置: 首页>>代码示例>>Java>>正文


Java Log类代码示例

本文整理汇总了Java中com.example.android.common.logger.Log的典型用法代码示例。如果您正苦于以下问题:Java Log类的具体用法?Java Log怎么用?Java Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Log类属于com.example.android.common.logger包,在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ConnectedThread

import com.example.android.common.logger.Log; //导入依赖的package包/类
public ConnectedThread(BluetoothSocket socket, String socketType) {
    Log.d(TAG, "create ConnectedThread: " + socketType);
    mmSocket = socket;
    InputStream tmpIn = null;
    OutputStream tmpOut = null;

    // Get the BluetoothSocket input and output streams
    try {
        tmpIn = socket.getInputStream();
        tmpOut = socket.getOutputStream();
    } catch (IOException e) {
        Log.e(TAG, "temp sockets not created", e);
    }

    mmInStream = tmpIn;
    mmOutStream = tmpOut;
    mState = STATE_CONNECTED;
}
 
开发者ID:hardik-dadhich,项目名称:bluetooth-chat-appliction,代码行数:19,代码来源:BluetoothChatService.java

示例2: initializeLogging

import com.example.android.common.logger.Log; //导入依赖的package包/类
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:MainActivity.java

示例3: onOptionsItemSelected

import com.example.android.common.logger.Log; //导入依赖的package包/类
/**
 * Respond to the user's selection of the Refresh action item. Start the SwipeRefreshLayout
 * progress bar, then initiate the background task that refreshes the content.
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_clear:
            Log.i(LOG_TAG, "Clear menu item selected");
            mListAdapter.clear();
            return true;

        case R.id.menu_refresh:
            Log.i(LOG_TAG, "Refresh menu item selected");

            // We make sure that the SwipeRefreshLayout is displaying it's refreshing indicator
            if (!mSwipeRefreshLayout.isRefreshing()) {
                mSwipeRefreshLayout.setRefreshing(true);
            }

            // Start our refresh background task
            initiateRefresh();

            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:SwipeRefreshMultipleViewsFragment.java

示例4: doDiscovery

import com.example.android.common.logger.Log; //导入依赖的package包/类
/**
 * Start device discover with the BluetoothAdapter
 */
private void doDiscovery() {
    Log.d(TAG, "doDiscovery()");

    // Indicate scanning in the title
    setProgressBarIndeterminateVisibility(true);
    setTitle(R.string.scanning);

    // Turn on sub-title for new devices
    findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);

    // If we're already discovering, stop it
    if (mBtAdapter.isDiscovering()) {
        mBtAdapter.cancelDiscovery();
    }

    // Request discover from BluetoothAdapter
    mBtAdapter.startDiscovery();
}
 
开发者ID:hardik-dadhich,项目名称:bluetooth-chat-appliction,代码行数:22,代码来源:DeviceListActivity.java

示例5: connect

import com.example.android.common.logger.Log; //导入依赖的package包/类
/**
 * Start the ConnectThread to initiate a connection to a remote device.
 *
 * @param device The BluetoothDevice to connect
 * @param secure Socket Security type - Secure (true) , Insecure (false)
 */
public synchronized void connect(BluetoothDevice device, boolean secure) {
    Log.d(TAG, "connect to: " + device);

    // Cancel any thread attempting to make a connection
    if (mState == STATE_CONNECTING) {
        if (mConnectThread != null) {
            mConnectThread.cancel();
            mConnectThread = null;
        }
    }

    // Cancel any thread currently running a connection
    if (mConnectedThread != null) {
        mConnectedThread.cancel();
        mConnectedThread = null;
    }

    // Start the thread to connect with the given device
    mConnectThread = new ConnectThread(device, secure);
    mConnectThread.start();
    // Update UI title
    updateUserInterfaceTitle();
}
 
开发者ID:hardik-dadhich,项目名称:bluetooth-chat-appliction,代码行数:30,代码来源:BluetoothChatService.java

示例6: AcceptThread

import com.example.android.common.logger.Log; //导入依赖的package包/类
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
    mState = STATE_LISTEN;
}
 
开发者ID:hardik-dadhich,项目名称:bluetooth-chat-appliction,代码行数:20,代码来源:BluetoothChatService.java

示例7: ConnectThread

import com.example.android.common.logger.Log; //导入依赖的package包/类
public ConnectThread(BluetoothDevice device, boolean secure) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        if (secure) {
            tmp = device.createRfcommSocketToServiceRecord(
                    MY_UUID_SECURE);
        } else {
            tmp = device.createInsecureRfcommSocketToServiceRecord(
                    MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
    }
    mmSocket = tmp;
    mState = STATE_CONNECTING;
}
 
开发者ID:hardik-dadhich,项目名称:bluetooth-chat-appliction,代码行数:22,代码来源:BluetoothChatService.java

示例8: run

import com.example.android.common.logger.Log; //导入依赖的package包/类
public void run() {
    Log.i(TAG, "BEGIN mConnectedThread");
    byte[] buffer = new byte[1024];
    int bytes;

    // Keep listening to the InputStream while connected
    while (mState == STATE_CONNECTED) {
        try {
            // Read from the InputStream
            bytes = mmInStream.read(buffer);

            // Send the obtained bytes to the UI Activity
            mHandler.obtainMessage(Constants.MESSAGE_READ, bytes, -1, buffer)
                    .sendToTarget();
        } catch (IOException e) {
            Log.e(TAG, "disconnected", e);
            connectionLost();
            break;
        }
    }
}
 
开发者ID:hardik-dadhich,项目名称:bluetooth-chat-appliction,代码行数:22,代码来源:BluetoothChatService.java

示例9: onActivityResult

import com.example.android.common.logger.Log; //导入依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CONNECT_DEVICE_SECURE:
            // When DeviceListActivity returns with a device to connect
            if (resultCode == Activity.RESULT_OK) {
                connectDevice(data, true); //deleting this prevents crash
            }
            break;

        case REQUEST_ENABLE_BT:
            // When the request to enable Bluetooth returns
            if (resultCode == Activity.RESULT_OK) {
                // Bluetooth is now enabled, so set up a chat session
                setupChat();
            } else {
                // User did not enable Bluetooth or an error occurred
                Log.d(TAG, "BT not enabled");
                Toast.makeText(getActivity(), R.string.bt_not_enabled_leaving,
                        Toast.LENGTH_SHORT).show();
                getActivity().finish();
            }
    }
}
 
开发者ID:tkmarsh,项目名称:SmartRC,代码行数:24,代码来源:BluetoothChatFragment.java

示例10: doDiscovery

import com.example.android.common.logger.Log; //导入依赖的package包/类
private void doDiscovery() {
    Log.d(TAG, "doDiscovery()");

    // Indicate scanning in the title
    setProgressBarIndeterminateVisibility(true);
    setTitle(R.string.scanning);

    // Turn on sub-title for new devices
    findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);

    // If we're already discovering, stop it
    if (mBtAdapter.isDiscovering()) {
        mBtAdapter.cancelDiscovery();
    }

    // Request discover from BluetoothAdapter
    mBtAdapter.startDiscovery();
}
 
开发者ID:tkmarsh,项目名称:SmartRC,代码行数:19,代码来源:DeviceListActivity.java

示例11: initializeLogging

import com.example.android.common.logger.Log; //导入依赖的package包/类
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
   LogFragment logFragment = (LogFragment) getSupportFragmentManager().findFragmentById(R.id.log_fragment);
    //msgFilter.setNext(logFragment.getLogView());
    Log.i(TAG, "Ready");
}
 
开发者ID:tkmarsh,项目名称:SmartRC,代码行数:18,代码来源:MainActivity.java

示例12: connect

import com.example.android.common.logger.Log; //导入依赖的package包/类
public synchronized void connect(BluetoothDevice device, boolean secure) {
    Log.d(TAG, "connect to: " + device);

    // Cancel any thread attempting to make a connection
    if (mState == STATE_CONNECTING) {
        if (mConnectThread != null) {
            mConnectThread.cancel();
            mConnectThread = null;
        }
    }

    // Cancel any thread currently running a connection
    if (mConnectedThread != null) {
        mConnectedThread.cancel();
        mConnectedThread = null;
    }

    // Start the thread to connect with the given device
    mConnectThread = new ConnectThread(device, secure);
    mConnectThread.start();
    setState(STATE_CONNECTING);
}
 
开发者ID:tkmarsh,项目名称:SmartRC,代码行数:23,代码来源:BluetoothChatService.java

示例13: stop

import com.example.android.common.logger.Log; //导入依赖的package包/类
public synchronized void stop() {
    Log.d(TAG, "stop");

    if (mConnectThread != null) {
        mConnectThread.cancel();
        mConnectThread = null;
    }

    if (mConnectedThread != null) {
        mConnectedThread.cancel();
        mConnectedThread = null;
    }

    if (mSecureAcceptThread != null) {
        mSecureAcceptThread.cancel();
        mSecureAcceptThread = null;
    }

    if (mInsecureAcceptThread != null) {
        mInsecureAcceptThread.cancel();
        mInsecureAcceptThread = null;
    }
    setState(STATE_NONE);
}
 
开发者ID:tkmarsh,项目名称:SmartRC,代码行数:25,代码来源:BluetoothChatService.java

示例14: AcceptThread

import com.example.android.common.logger.Log; //导入依赖的package包/类
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
}
 
开发者ID:tkmarsh,项目名称:SmartRC,代码行数:19,代码来源:BluetoothChatService.java

示例15: ConnectThread

import com.example.android.common.logger.Log; //导入依赖的package包/类
public ConnectThread(BluetoothDevice device, boolean secure) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        if (secure) {
            tmp = device.createRfcommSocketToServiceRecord(
                    MY_UUID_SECURE);
        } else {
            tmp = device.createInsecureRfcommSocketToServiceRecord(
                    MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
    }
    mmSocket = tmp;
}
 
开发者ID:tkmarsh,项目名称:SmartRC,代码行数:21,代码来源:BluetoothChatService.java


注:本文中的com.example.android.common.logger.Log类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。