Java Code Examples for android.os.Message#setData()

The following examples show how to use android.os.Message#setData() . 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: AutomaticAcquisition.java    From ans-android-sdk with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 构建 TrackAppEnd Message
 *
 * @return Message
 */

private Message makeTrackAppEndMsg() {
    Message msg = Message.obtain();
    msg.what = TRACK_APP_END;
    Bundle bundle = new Bundle();
    String endInfo = SharedUtil.getString(context, Constants.APP_END_INFO,"");
    if (!TextUtils.isEmpty(endInfo)) {
        bundle.putString(Constants.APP_END_INFO,
                new String(Base64.decode(endInfo.getBytes(), Base64.DEFAULT)));
    }
    String time = SharedUtil.getString(context, Constants.LAST_OP_TIME,"");
    if(!TextUtils.isEmpty(time)) {
        bundle.putString(Constants.LAST_OP_TIME, time);
    }
    msg.setData(bundle);
    return msg;
}
 
Example 2
Source File: Command.java    From RedEnvelopeAssistant with MIT License 6 votes vote down vote up
protected void output(int id, String line)
{
    if (mHandler != null && handlerEnabled)
    {
        Message msg = mHandler.obtainMessage();
        Bundle bundle = new Bundle();
        bundle.putInt(CommandHandler.ACTION, CommandHandler.COMMAND_OUTPUT);
        bundle.putString(CommandHandler.TEXT, line);
        msg.setData(bundle);
        mHandler.sendMessage(msg);
    }
    else
    {
        commandOutput(id, line);
    }
}
 
Example 3
Source File: SignalCheck.java    From letv with Apache License 2.0 6 votes vote down vote up
static /* synthetic */ void a(SignalCheck signalCheck, Message message) {
    message.what = 0;
    Bundle bundle = new Bundle();
    if (signalCheck.n == 1 || signalCheck.n == 3) {
        signalCheck.n = -1;
        signalCheck.m = -1;
    }
    bundle.putInt("kukid", signalCheck.m);
    bundle.putInt("kukid_type", signalCheck.n);
    message.setData(bundle);
    signalCheck.r.handleMessage(message);
    if (signalCheck.m < 0) {
        b.a("kukid is no exists");
        return;
    }
    b.a("kukid is the " + (signalCheck.q == signalCheck.m ? "same" : "different"));
    signalCheck.q = signalCheck.m;
}
 
Example 4
Source File: MapEventSource.java    From android_maplib with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Send layer changed event to all listeners
 *
 * @param layer
 *         A changed layer
 */
@Override
protected void onLayerChanged(ILayer layer)
{
    super.onLayerChanged(layer);
    if (mListeners == null) {
        return;
    }

    Bundle bundle = new Bundle();
    bundle.putInt(BUNDLE_ID_KEY, layer.getId());
    bundle.putInt(BUNDLE_TYPE_KEY, EVENT_onLayerChanged);

    Message msg = new Message();
    msg.setData(bundle);
    mHandler.sendMessage(msg);
}
 
Example 5
Source File: AlbumMidAdController.java    From letv with Apache License 2.0 6 votes vote down vote up
public void notifyMidAdStartToAdSdk() {
    if (this.mActivity.getFlow() != null && this.mActivity.getFlow().mIsMidAdFinished) {
        LogInfo.log("zhaosumin", "中贴广告开始");
        if (this.mActivity.getHalfFragment() != null) {
            this.mActivity.getVideoController().setVisibilityForMore(false);
            this.mActivity.getHalfFragment().closeExpand();
        }
        this.mActivity.getFlow().mIsMidAdFinished = false;
        reSet();
        this.mActivity.getVideoController().setControllerVisibility(8, true);
        setVisibleForBarrage(false);
        Message msg = new Message();
        msg.what = 10;
        Bundle bundle = new Bundle();
        bundle.putInt(ClientCPConstant.KEY_AD_TYPE, 2);
        msg.setData(bundle);
        this.mActivity.getPlayAdListener().notifyADEvent(msg);
        this.mActivity.getAlbumPlayFragment().setVisibityForWaterMark(false);
    }
}
 
Example 6
Source File: EUExWindow.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setLoadingImagePath(String[] parm) {
    if (parm.length < 1) {
        return;
    }
    Message msg = new Message();
    msg.obj = this;
    msg.what = MSG_FUNCTION_SETLOADINGIMAGEPATH;
    Bundle bd = new Bundle();
    bd.putStringArray(TAG_BUNDLE_PARAM, parm);
    msg.setData(bd);
    mHandler.sendMessage(msg);
}
 
Example 7
Source File: BluetoothManager.java    From retrowatch with Apache License 2.0 5 votes vote down vote up
/**
 * Start the ConnectedThread to begin managing a Bluetooth connection
 * @param socket  The BluetoothSocket on which the connection was made
 * @param device  The BluetoothDevice that has been connected
 */
public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
	Logs.d(TAG, "connected");

    // Cancel the thread that completed the connection
    if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}

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

    // Cancel the accept thread because we only want to connect to one device
    if (mAcceptThread != null) {mAcceptThread.cancel(); mAcceptThread = null;}

    // Start the thread to manage the connection and perform transmissions
    mConnectedThread = new ConnectedThread(socket);
    mConnectedThread.start();

    // Send the name of the connected device back to the UI Activity
    Message msg = mHandler.obtainMessage(MESSAGE_DEVICE_NAME);
    Bundle bundle = new Bundle();
    bundle.putString(Constants.SERVICE_HANDLER_MSG_KEY_DEVICE_ADDRESS, device.getAddress());
    bundle.putString(Constants.SERVICE_HANDLER_MSG_KEY_DEVICE_NAME, device.getName());
    msg.setData(bundle);
    mHandler.sendMessage(msg);

    setState(STATE_CONNECTED);
}
 
Example 8
Source File: DownloaderServiceMarshaller.java    From UnityOBBDownloader with Apache License 2.0 5 votes vote down vote up
private void send(int method, Bundle params) {
    Message m = Message.obtain(null, method);
    m.setData(params);
    try {
        mMsg.send(m);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
Example 9
Source File: BinderPool.java    From MagicMessenger with Apache License 2.0 5 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            Message message = Message.obtain(handler, Constant.SEND_MSG_TO_TARGET);
            message.replyTo = messenger;
            message.setData(extras);
            sendMsg(message);
        }
    }
    return START_NOT_STICKY;
}
 
Example 10
Source File: CallActivity.java    From sealrtc-android with MIT License 5 votes vote down vote up
private void updateNetworkSpeedInfo(StatusReport statusReport) {
    if (networkSpeedHandler != null) {
        Message message = new Message();
        Bundle bundle = new Bundle();
        message.what = 1;
        bundle.putLong("send", statusReport.bitRateSend);
        bundle.putLong("rcv", statusReport.bitRateRcv);
        message.setData(bundle);
        networkSpeedHandler.sendMessage(message);
    }
}
 
Example 11
Source File: EUExWindow.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
@AppCanAPI
public void setAutorotateEnable(String[] parm) {
    if (parm.length < 1) {
        return;
    }
    Message msg = new Message();
    msg.obj = this;
    msg.what = MSG_FUNCTION_SETAUTOROTATEENABLE;
    Bundle bd = new Bundle();
    bd.putStringArray(TAG_BUNDLE_PARAM, parm);
    msg.setData(bd);
    mHandler.sendMessage(msg);
}
 
Example 12
Source File: appPDP.java    From DroidForce with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void deployPolicy(File pathToPolicy) {
	Log.d(TAG, "deployPolicy method");
	try {
		// Read in the policy file
		BufferedReader rdr = new BufferedReader(
				new FileReader(pathToPolicy));
		String line = "";
		String data = "";
		while ((line = rdr.readLine()) != null)
			data += line + "\n";
		rdr.close();
		Log.d(TAG, "Policy file read.");

		// Deploy the policy
		Bundle event = new Bundle();
		event.putString("policy", data);

		Message m = Message.obtain();
		m.setData(event);
		Log.d(TAG, "sending deployment message");
		deployPolicyConnection.getMessenger().send(m);
		Log.d(TAG, "deployment message sent");

		Toast.makeText(getApplicationContext(), "Policy deployed",
				Toast.LENGTH_LONG).show();
	} catch (Exception e) {
		Log.e(TAG, "Exception during deployment" + e);
		Log.e(TAG, e.getMessage());
		e.printStackTrace();
	}
}
 
Example 13
Source File: Command.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
protected final void output(int id, String line) {
  totalOutput++;

  if (mHandler != null && handlerEnabled) {
    Message msg = mHandler.obtainMessage();
    Bundle bundle = new Bundle();
    bundle.putInt(CommandHandler.ACTION, CommandHandler.COMMAND_OUTPUT);
    bundle.putString(CommandHandler.TEXT, line);
    msg.setData(bundle);
    mHandler.sendMessage(msg);
  } else {
    commandOutput(id, line);
  }
}
 
Example 14
Source File: MessageClient.java    From 12306XposedPlugin with GNU General Public License v3.0 5 votes vote down vote up
public void sendToTarget(int what, String value, @Nullable Callback callback) {
    Message message = Message.obtain(null, what);
    Bundle bundle = new Bundle();
    bundle.putString("data", value);
    message.setData(bundle);
    sendToTarget(message, callback);
}
 
Example 15
Source File: BluetoothService.java    From UnityBluetoothPlugin with Apache License 2.0 5 votes vote down vote up
private void connectionFailed() {
    setState(STATE_LISTEN);
    Message msg = this.mHandler.obtainMessage(BluetoothPlugin.MESSAGE_TOAST);
    Bundle bundle = new Bundle();
    bundle.putString(this.TOAST, "Unable to connect device");
    msg.setData(bundle);
    this.mHandler.sendMessage(msg);
}
 
Example 16
Source File: NTRIPService.java    From api-ntrip-java-client with MIT License 4 votes vote down vote up
private void sendStatusMessageToUI() {
	// Build bundle
	String textFix;
	switch (FixType) {
	case 0:
		textFix = "Invalid";
		break;
	case 1:
		textFix = "GPS";
		break;
	case 2:
		textFix = "DGPS";
		break;
	case 3:
		textFix = "PPS";
		break;
	case 4:
		textFix = "RTK";
		break;
	case 5:
		textFix = "FloatRTK";
		break;
	case 6:
		textFix = "Estimated";
		break;
	case 7:
		textFix = "Manual";
		break;
	case 8:
		textFix = "Simulation";
		break;
	case 9:
		textFix = "WAAS";
		break;
	case 10:
		textFix = "No Data";
		break;
	default:
		textFix = "Unknown";
	}
	if (FixType < 10) {
		textFix += ":" + SatsTracked;
	}

	Bundle b = new Bundle();
	b.putString("fixtype", textFix);
	b.putString("info1", GetOutputInfo(outInfo1));
	b.putString("info2", GetOutputInfo(outInfo2));

	for (int i = mClients.size() - 1; i >= 0; i--) {
		try {
			Message msg = Message.obtain(null, MSG_UPDATE_STATUS);
			msg.setData(b);
			mClients.get(i).send(msg);
		} catch (RemoteException e) {
			// The client is dead. Remove it from the list; we are going
			// through the list from back to front so this is safe to do
			// inside the loop.
			mClients.remove(i);
		}
	}
	TicksSinceLastStatusSent = 0; // Reset to zero
}
 
Example 17
Source File: SettingFragment.java    From RelaxFinger with GNU General Public License v2.0 4 votes vote down vote up
public void sendMsg(int what, String name, boolean action) {

        Message message = Message.obtain();

        message.what = what;

        Bundle bundle = new Bundle();

        bundle.putBoolean(name,action);

        message.setData(bundle);

        try {
            if(SettingActivity.sMessenger != null){

                SettingActivity.sMessenger.send(message);

            }

        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
 
Example 18
Source File: TransportBroker.java    From sdl_java_suite with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public boolean sendPacketToRouterService(SdlPacket packet) { //We use ints because that is all that is supported by the outputstream class
    //Log.d(TAG,whereToReply + "Sending packet to router service");

    if (routerServiceMessenger == null) {
        Log.d(TAG, whereToReply + " tried to send packet, but no where to send");
        return false;
    }
    if (packet == null
        //|| offset<0
        //|| count<0
            ) {//|| count>(bytes.length-offset)){
        Log.w(TAG, whereToReply + "incorrect params supplied");
        return false;
    }
    byte[] bytes = packet.constructPacket();
    if (bytes.length < ByteArrayMessageSpliter.MAX_BINDER_SIZE) {//Determine if this is under the packet length.
        Message message = Message.obtain(); //Do we need to always obtain new? or can we just swap bundles?
        message.what = TransportConstants.ROUTER_SEND_PACKET;
        Bundle bundle = new Bundle();
        if (routerServiceVersion < TransportConstants.RouterServiceVersions.APPID_STRING) {
            bundle.putLong(TransportConstants.APP_ID_EXTRA, convertAppId(appId));
        }
        bundle.putString(TransportConstants.APP_ID_EXTRA_STRING, appId);
        bundle.putByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME, bytes); //Do we just change this to the args and objs
        bundle.putInt(TransportConstants.BYTES_TO_SEND_EXTRA_OFFSET, 0);
        bundle.putInt(TransportConstants.BYTES_TO_SEND_EXTRA_COUNT, bytes.length);
        bundle.putInt(TransportConstants.BYTES_TO_SEND_FLAGS, TransportConstants.BYTES_TO_SEND_FLAG_NONE);
        bundle.putInt(TransportConstants.PACKET_PRIORITY_COEFFICIENT, packet.getPrioirtyCoefficient());
        if (packet.getTransportRecord() != null) {
            //Log.d(TAG, "Sending packet on transport " + packet.getTransportType().name());
            TransportRecord record = packet.getTransportRecord();
            bundle.putString(TransportConstants.TRANSPORT_TYPE, record.getType().name());
            bundle.putString(TransportConstants.TRANSPORT_ADDRESS, record.getAddress());
        } else {
            //Log.d(TAG, "No transport to be found");
        }
        message.setData(bundle);

        sendMessageToRouterService(message);
        return true;
    } else { //Message is too big for IPC transaction
        //Log.w(TAG, "Message too big for single IPC transaction. Breaking apart. Size - " +  bytes.length);
        ByteArrayMessageSpliter splitter = new ByteArrayMessageSpliter(appId, TransportConstants.ROUTER_SEND_PACKET, bytes, packet.getPrioirtyCoefficient());
        splitter.setRouterServiceVersion(routerServiceVersion);
        splitter.setTransportRecord(packet.getTransportRecord());
        while (splitter.isActive()) {
            sendMessageToRouterService(splitter.nextMessage());
        }
        return splitter.close();
    }

}
 
Example 19
Source File: SettingFragment.java    From RelaxFinger with GNU General Public License v2.0 4 votes vote down vote up
public void sendMsg(int what, String name, String msg) {

        Message message = Message.obtain();

        message.what = what;

        Bundle bundle = new Bundle();

        bundle.putString(name,msg);

        message.setData(bundle);

        try {
            if(SettingActivity.sMessenger != null){

                SettingActivity.sMessenger.send(message);
            }
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
 
Example 20
Source File: HandlerUtils.java    From UltimateAndroid with Apache License 2.0 3 votes vote down vote up
/**
 * Pushes a message containing bundle onto the end of the message queue after all pending messages before the current time.
 *
 * @param handler
 * @param what
 * @param bundle
 */
public static void sendMessageHandler(Handler handler, int what, Bundle bundle) {
    Message message = new Message();
    message.what = what;
    message.setData(bundle);
    handler.sendMessage(message);
}