Java Code Examples for org.appcelerator.kroll.common.Log#w()

The following examples show how to use org.appcelerator.kroll.common.Log#w() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NovarumbluetoothModule.java    From NovarumBluetooth with MIT License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) 
{
    Message msg = Message.obtain();
    String action = intent.getAction();
    
    if(BluetoothDevice.ACTION_FOUND.equals(action))
    {

    	bluetoothDevice        = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    	BluetoothClass blclass = intent.getParcelableExtra(BluetoothDevice.EXTRA_CLASS);
    	
    	int Majorclass = blclass.getMajorDeviceClass();
    	int minorclass = blclass.getDeviceClass();
    	
    	
        devicelist = new KrollDict();
        
        try
        {
        	devicelist.put("name",bluetoothDevice.getName());
        	devicelist.put("macaddress",bluetoothDevice.getAddress());
        	devicelist.put("pairedstatus",bluetoothDevice.getBondState());
        }
        catch (Exception e) 
        {
            Log.w(TAG, "devicesFound exception: "+e.getMessage());
            postError(e.getMessage());
        }

        devicesFound();
        
    }           
}
 
Example 2
Source File: NovarumbluetoothModule.java    From NovarumBluetooth with MIT License 4 votes vote down vote up
@Kroll.method
public boolean connect(String devicemac)
{
	if(devicemac == null)
	   return false;
	
	//Check if we should use the service//
	if(useService)
	{
		
		//Start Service//
		try
		{
			//Get Current activity//
			TiApplication appContext = TiApplication.getInstance();
			Activity activity = appContext.getCurrentActivity();
			
			BluetoothServiceIntent = new TiIntentWrapper(new Intent(activity,BluetoothService.class));
			BluetoothServiceIntent.getIntent().putExtra("MacAddress",devicemac);
			appContext.startService(BluetoothServiceIntent.getIntent());
			
			return true;
		}
		catch(Exception e)
		{
			Log.w(TAG,"error on creating bluetooth service: "+e.getMessage());
			return false;					
		}
		
		
	}
	else
	{		
		bluetoothDevice = bluetoothAdapter.getRemoteDevice(devicemac);
		
		if (bluetoothDevice.getBondState() == BluetoothDevice.BOND_NONE) 
		{
			if(pairDevice(bluetoothDevice))
			{
				
				return socketConnect(bluetoothDevice);
			}
			else
			{
				postError("Could not pair device");
				return false;
			}
		}
		else
		{
			return socketConnect(bluetoothDevice);				
		}
	}
}
 
Example 3
Source File: NovarumbluetoothModule.java    From NovarumBluetooth with MIT License 3 votes vote down vote up
public void discoverabilityResult(int Result)
{
	KrollDict data = new KrollDict();
	
	data.put("result",Integer.toString(Result));
	
	Log.w(TAG,"NovarumBluetooth Discoverability Result" + Result);
	
	fireEvent("nb_onDiscoverabilityResult", data);
}