Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 239
Registered: ‎07-26-2010
My Device: Z10
My Carrier: Telkomsel

Whatsapp invoked instead of native media player

I use this code to play a encrypted video un BB builtin media player

 

public void playIt(byte[] bytes, String key){
		byte[] decrypted_bytes = null;
		
		try {
			decrypted_bytes = CryptoUtil.decrypt(bytes, key);
		}
		catch (UnsupportedEncodingException use){
			use.printStackTrace();
		}
		
		Invocation invocation = new Invocation();
		invocation.setData(decrypted_bytes);
		invocation.setType("video/mp4");
		invocation.setResponseRequired(true);
		invocation.setAction(ContentHandler.ACTION_OPEN);

		Registry reg = Registry.getRegistry(Application.getApplication().getClass().getName());
		try {
			reg.invoke(invocation);
			Invocation response = reg.getResponse(true);
			if(response.getStatus() == Invocation.OK) invocation.setAction(ContentHandler.ACTION_STOP);
		} catch (IllegalArgumentException e1) {
			e1.printStackTrace();
		} catch (ContentHandlerException e1) {
			e1.printStackTrace();
		} catch (SecurityException e1) {
			e1.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		finally{
			decrypted_bytes = null;
		}
	}

 The problem is if Whatsapp is installed, then Whatsapp will be invoked, instead of the built-in media player.

Anybody experienced this?