in android Asmack i want to set invisible user.
and i used from every mode but it didn't works. after that i used from Type ..
when i set type unavailable, it works . but there is a problem .. my pocket listener doesn't work .. and i cant get any thing from user .. What can i do .. Thanks a lot.
Type type = Presence.Type.available;
Mode OWN = Mode.available;
if (DB_STATUS.avibilaty.toString().equals("")) {
OWN = Mode.available;
} else if (DB_STATUS.avibilaty.toString().equals("away")) {
OWN = Mode.away;
} else if (DB_STATUS.avibilaty.toString().equals(
"available")) {
OWN = Mode.available;
} else if (DB_STATUS.avibilaty.toString().equals(
"unavailable")) {
type = Presence.Type.unavailable;
} else if (DB_STATUS.avibilaty.toString().equals("busy")) {
OWN = Mode.dnd;
}
Presence presence = new Presence(type);
presence.setMode(OWN);
Related
Is there any way to automatically detect OTP in a webview?
There is a mobile no. to be verified using a an OTP and OTP is to be detected in in app webview.
Thanks in advance
Whenever you get OTP via sms and notify by receiver, then inside webview whichever input text inside you want to add your OTP there you need to do something like this?
String otp = "OTP_FROM_YOUR_RECEIVER";
webview.loadUrl("javascript:document.getElementById('otp_input').value = '"+otp+"';");
Above code is just example you need to change as per your requirements and all.
Here the code in Kotlin:
if (Build.VERSION.SDK_INT >= 19) {
mWebView!!.evaluateJavascript(getString(R.string.fill_otp) + "\"$extractedOTP\";") { Log.e(TAG, it) }
} else {
mWebView!!.loadUrl(getString(R.string.fill_otp) + "\"$extractedOTP\";")
}
Put "fill_otp" in strings file:
<string name="fill_otp">javascript: function getInputs() {
var ary = [];
var inputs = document.getElementsByTagName(\"input\");
for (var i=0; i<inputs.length; i++)
{
if (inputs[i].type.toLowerCase() == \"password\"||
inputs[i].type.toLowerCase() == \"tel\"||
inputs[i].type.toLowerCase() == \"number\"||
inputs[i].type.toLowerCase() == \"text\"){
if(!inputs[i].hidden&&!inputs[i].disabled){
ary.push(inputs[i]);
}
}
}
return ary;
}
var array= getInputs();
array[0].value=</string>
I'm making a 2-player android game using UNET. Now, all the movements of the host's objects are syncing across the network therefore it's working fine. But when the object on the client's side moves, it moves but it doesn't move in the host's screen. Therefore, the movement is not syncing.
I already attached NetworkIdentity, NetworkTransform, and PlayerController script to it. As well as the box collider (for the raycast).
The server and the client has the same script in the PlayerController but the only difference is, host could only move objects with Player tags and objects with Tagger tags for the client.
void Update () {
if(!isLocalPlayer){
return;
}
if(isServer){
Debug.Log("Server here.");
if (Input.GetMouseButtonDown(0))
{
Vector2 cubeRay = Camera.main.ScreenToWorldPoint(Input.mousePosition);
RaycastHit2D cubeHit = Physics2D.Raycast(cubeRay, Vector2.zero);
if (cubeHit)
{
if(cubeHit.transform.tag=="Player")
{
if (this.target != null)
{
SelectMove sm = this.target.GetComponent<SelectMove>();
if (sm != null) { sm.enabled = false; }
}
target = cubeHit.transform.gameObject;
selectedPlayer();
}
}
}
}
if(!isServer){
Debug.Log("Client here.");
if (Input.GetMouseButtonDown(0))
{
Vector2 cubeRay = Camera.main.ScreenToWorldPoint(Input.mousePosition);
RaycastHit2D cubeHit = Physics2D.Raycast(cubeRay, Vector2.zero);
if (cubeHit)
{
if(cubeHit.transform.tag=="Tagger")
{
if (this.target != null)
{
SelectMove sm = this.target.GetComponent<SelectMove>();
if (sm != null) { sm.enabled = false; }
}
target = cubeHit.transform.gameObject;
selectedPlayer();
}
}
}
}
}
I'm using (!isServer) to identify client because isClient sometimes doesn't work fine on my project. I also tried using it again to test it out, but still no luck.
You dont need to use tags to move players this one script PlayerController is enough using only isLocalPlayer check and try disabling this script using !isLocalPlayer on both clients. Use this for reference http://docs.unity3d.com/Manual/UNetSetup.html and check thier sample tutorial
I'm using CastCompanionLibrary-Android and I'm trying to set custom TextTrackStyle for the captions.
I'm setting this TexTextStyle to the MediaInfo while I'm creating it:
// set CC style
TextTrackStyle textTrackStyle = new TextTrackStyle();
textTrackStyle.setBackgroundColor(Color.parseColor("#FFFFFF"));
textTrackStyle.setForegroundColor(ContextCompat.getColor(mContext, R.color.blue));
MediaInfo mediaInfo = new MediaInfo.Builder(url)
.setStreamDuration(movieVideoItem.getDuration())
.setStreamType(MediaInfo.STREAM_TYPE_NONE)
.setContentType(type)
.setMetadata(mediaMetadata)
.setMediaTracks(tracks)
.setCustomData(customData)
.setTextTrackStyle(textTrackStyle)
.build();
But there is no visible result on the Chromecast side. I also tried to change VideoCastManager method setTextTrackStyle:
public void setTextTrackStyle(TextTrackStyle style) {
// CUSTOM TEXT TRACK STYLE HERE
TextTrackStyle textTrackStyle = new TextTrackStyle();
textTrackStyle.setBackgroundColor(Color.parseColor("#FF0000"));
textTrackStyle.setForegroundColor(Color.parseColor("#0000FF"));
mRemoteMediaPlayer.setTextTrackStyle(mApiClient, textTrackStyle)
.setResultCallback(new ResultCallback<MediaChannelResult>() {
#Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
onFailed(R.string.ccl_failed_to_set_track_style,
result.getStatus().getStatusCode());
}
}
});
for (VideoCastConsumer consumer : mVideoConsumers) {
try {
consumer.onTextTrackStyleChanged(textTrackStyle);
} catch (Exception e) {
LOGE(TAG, "onTextTrackStyleChanged(): Failed to inform " + consumer, e);
}
}
}
But in this ResultCallback I'm getting error code 2103 which I found here: developers google
public static final int REPLACED
Status code indicating that the request's progress is no longer being tracked because another request of the same type has been made before the first request completed.
Constant Value: 2103
I don't know what this error code means, or what I'm doing wrong. The Chromecast implementation should be able to handle custom TextTrackStyle (at least for embedded VTT type)
MediaManager.onMetadataLoaded = function (event) {
.......
console.log("### RESOLVED TEXT TRACK TYPE " + textTrackType);
if (textTrackType ==
sampleplayer.TextTrackType.SIDE_LOADED_TTML &&
event.message && event.message.activeTrackIds && event.message.media &&
event.message.media.tracks) {
_processTtmlCues(
event.message.activeTrackIds, event.message.media.tracks);
} else if (!textTrackType || textTrackType == sampleplayer.TextTrackType.SIDE_LOADED_UNSUPPORTED) {
// If we do not have a textTrackType, check if the tracks are embedded
_maybeLoadEmbeddedTracksMetadata(event);
}
MediaManager['onMetadataLoadedOrig'](event);
}
function _maybeLoadEmbeddedTracksMetadata(info) {
if (!info.message || !info.message.media) {
return;
}
var tracksInfo = _readInBandTracksInfo();
if (tracksInfo) {
textTrackType = sampleplayer.TextTrackType.EMBEDDED;
tracksInfo.textTrackStyle = info.message.media.textTrackStyle;
MediaManager.loadTracksInfo(tracksInfo);
}
}
The result on the Chromecast is just white text with black background.
// EDIT Chromecast receiver log added:
There is Chromecast receiver log where I found some TextTrackStyle but this is not my style that I'm trying to set:
Received message: {"data":"{\"requestId\":4,\"type\":\"EDIT_TRACKS_INFO\",\"textTrackStyle\":{\"fontScale\":1,\"foregroundColor\":\"#4285F4FF\",\"backgroundColor\":\"#FFFFFFFF\"},\"mediaSessionId\":1}"
Those are different colors that I'm actually sending from my Android Sender app. I cannot see any TextTrackStyle inside the onLoad method at all. So I'm not sure if the problem is on Android side or on Chromecast side?
I succeed login and post my wall.
FB.API("me/photos", Facebook.HttpMethod.POST, Callback, wwwForm);// it works well.
FB.Feed("", "link", "link_name", ~~bulabula~~ );// it works well, too!
//////////////AND PLEASE SEE NEXT CODE. THIS IS PROBLEM.///////////////////
private string FriendSelectorTitle = "Share it with your friends!";
private string FriendSelectorMessage = "invite";
private string FriendSelectorFilters = "[\"all\"]";
private string FriendSelectorData = "{data}";
private string FriendSelectorExcludeIds = "";
private string FriendSelectorMax = "5";
private void CallAppRequestAsFriendSelector()
{
// If there's a Max Recipients specified, include it
int? maxRecipients = null;
if (FriendSelectorMax != "")
{
try
{
maxRecipients = Int32.Parse(FriendSelectorMax);
}
catch (Exception e)
{
//status = e.Message;
Debug.Log(e.Message);
}
}
// include the exclude ids
string[] excludeIds = (FriendSelectorExcludeIds == "") ? null : FriendSelectorExcludeIds.Split(',');
List<object> FriendSelectorFiltersArr = null;
if (!String.IsNullOrEmpty(FriendSelectorFilters))
{
try
{
FriendSelectorFiltersArr = Facebook.MiniJSON.Json.Deserialize(FriendSelectorFilters) as List<object>;
}
catch
{
throw new Exception("JSON Parse error");
}
}
FB.AppRequest(
FriendSelectorMessage,
null,
FriendSelectorFiltersArr,
excludeIds,
maxRecipients,
FriendSelectorData,
FriendSelectorTitle,
Callback
);
}
void Callback(FBResult result)
{
Debug.Log(result.Text);
}
/////////////////////////////////////////////////
it look like works well.
first, pop up friends selector dialog,
and I clicked some friends, and click 'done' button.
it will call 'Callback' Funtion, and
debug.log(FBResult.text); show follow like this.
{"request":"8939391818800568","to":["2446462595631736"],["189238719238719238"]}
but now, I don't know how to use these values. T_T
I think FB.feed(); is well done. So,
I try to
for( int i=0; i<usernum; i++ )
{
FB.feed( "id[user_index]" , bula~bula );
}
but failed.
becuase, fbresult.text is not string!!?
I try to split this string(fbresult.text), to get "to":["userid1 number"], ["userid2 number"]
but I failed and disappointed.
please someone help me.
Anybody who has a good idea???
I really want to send my message(pic or message) to friend's facebook wall.
You canĀ“t post to the wall of a friend anymore, since a very long time. In most (all?) cases this would be considered as spam, so they remove that possibility.
You can use the Send Dialog to send something to a friend, for example.
Still new to Java/android so trying to figure out the best way to code a multilevel if statement. What I'm trying to do is for a combat system that needs to check if player/npc is alive. If they are alive it then will check to see if they scored a critical hit. If they didn't critical hit then will see if they hit or missed.
combat = mydbhelper.getCombat();
startManagingCursor(combat);
if (playerCurHp == 0) {
combat.moveToPosition(11);
npcCombatStory = combat.getString(combat.getColumnIndex(dbhelper.KEY_COMBATDESC));
} else {
if (playerCritFlag.equals("Critical")) {
combat.moveToPosition(2);
playerCombatStory = combat.getString(combat.getColumnIndex(dbhelper.KEY_COMBATDESC));
} else {
if (playerHitFlag.equals("Hit")) {
combat.moveToPosition(1);
playerCombatStory = combat.getString(combat.getColumnIndex(dbhelper.KEY_COMBATDESC));
}
if (playerHitFlag.equals("Miss")) {
combat.moveToPosition(3);
playerCombatStory = combat.getString(combat.getColumnIndex(dbhelper.KEY_COMBATDESC));
}
}
}
if (npcCurHp == 0) {
combat.moveToPosition(10);
npcCombatStory = combat.getString(combat.getColumnIndex(dbhelper.KEY_COMBATDESC));
} else {
if (npcCritFlag.equals("Critical")) {
combat.moveToPosition(5);
npcCombatStory = combat.getString(combat.getColumnIndex(dbhelper.KEY_COMBATDESC));
} else {
if (npcHitFlag.equals("Hit")) {
combat.moveToPosition(4);
npcCombatStory = combat.getString(combat.getColumnIndex(dbhelper.KEY_COMBATDESC));
}
if(npcHitFlag.equals("Miss")) {
combat.moveToPosition(6);
npcCombatStory = combat.getString(combat.getColumnIndex(dbhelper.KEY_COMBATDESC));
}
}
}
Is what I'm using. Was working when I had the if statements all separate. But it would check each one and do actions I don't need (If they hit, pull String, if crit pull another, then if dead pull again). Trying to make it stop when it finds the "Flag" that matches. When doing my rolls if the player hits it sets the flag to "Hit" like below code.
Random attackRandom = new Random();
int attackRoll = attackRandom.nextInt(100);
totalAtt = attackRoll + bonusAttack + weaponAtt + stanceAtt;
Random defensiveRandom = new Random();
int defenseRoll = defensiveRandom.nextInt(100);
npcDef = defenseRoll + npcDodge + npcBonusDodge;
if (totalAtt > npcDef) {
playerHitFlag = "Hit";
playerDamage();
} else {
playerHitFlag = "Miss";
npcAttack();
}
At the end it takes these playerCombatStory and npcCombatStory strings and uses them to setText to show the player what happened on that turn of combat.
I think you are looking for the else if statement:
if (condition) {
}
else if (other_condition) {
}
else if (another_condition) {
}
else {
// There can only be one else statement in a given if-else block
}
Your question isn't clear. But meaningful advice can still be offered.
Personally, I find this code hard to read. I think it'll be hard to maintain in the future as your logic becomes more complex.
I think you need to decouple the logic of what's done from how you decide. Encapsulate what's done in a Command object and use a map or state machine to look up what to do.
I would change the type of npcCritFlag to int or enum. Then use switch statement with case
This should look much better and easier to understand