Hello,
ive some trouble.
I want that when i press IN the rect that some new rect appear but it look like the app do this random because sometimes when i press on the sreen i will get back empty variables or the wrong.
thats GamePaint.java
Code:
package com.floland.quaders;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.Toast;
public class GamePaint extends Activity {
Game drawView;
float x;
float y;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
drawView = new Game(this);
drawView.setBackgroundColor(Color.WHITE);
setContentView(drawView);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN){
x = event.getX();
y = event.getY();
Toast.makeText(GamePaint.this, " Y= " +y+ " X= " +x, Toast.LENGTH_LONG).show();
}
if (event.getAction() == MotionEvent.ACTION_UP) {
if((drawView.t <= y)&&(drawView.b >= y)&&(drawView.r <= x)&&(drawView.l >= x)) {
drawView = new Game(this);
drawView.setBackgroundColor(Color.WHITE);
setContentView(drawView);
Toast.makeText(GamePaint.this, "Richtig :)", Toast.LENGTH_SHORT).show();
Toast.makeText(GamePaint.this, "T= " + drawView.t + " B= " + drawView.b + " R= " + drawView.r + " L= " + drawView.l, Toast.LENGTH_LONG).show();
}
if((drawView.t >= y)&&(drawView.b <= y)&&(drawView.r >= x)&&(drawView.l <= x)) {
drawView = new Game(this);
drawView.setBackgroundColor(Color.WHITE);
setContentView(drawView);
Toast.makeText(GamePaint.this, "Richtig :)", Toast.LENGTH_SHORT).show();
Toast.makeText(GamePaint.this, "T= " + drawView.t + " B= " + drawView.b + " R= " + drawView.r + " L= " + drawView.l, Toast.LENGTH_LONG).show();
}
if((drawView.t <= y)&&(drawView.b >= y)&&(drawView.r >= x)&&(drawView.l <= x)) {
drawView = new Game(this);
drawView.setBackgroundColor(Color.WHITE);
setContentView(drawView);
Toast.makeText(GamePaint.this, "Richtig :)", Toast.LENGTH_SHORT).show();
Toast.makeText(GamePaint.this, "T= " + drawView.t + " B= " + drawView.b + " R= " + drawView.r + " L= " + drawView.l, Toast.LENGTH_LONG).show();
}
if((drawView.t >= y)&&(drawView.b <= y)&&(drawView.r <= x)&&(drawView.l >= x)) {
drawView = new Game(this);
drawView.setBackgroundColor(Color.WHITE);
setContentView(drawView);
Toast.makeText(GamePaint.this, "Richtig :)", Toast.LENGTH_SHORT).show();
Toast.makeText(GamePaint.this, "T= " + drawView.t + " B= " + drawView.b + " R= " + drawView.r + " L= " + drawView.l, Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(GamePaint.this, "Fehler", Toast.LENGTH_SHORT).show();
Toast.makeText(GamePaint.this, "T= " + drawView.t + " B= " + drawView.b + " R= " + drawView.r + " L= " + drawView.l, Toast.LENGTH_LONG).show();
}
}
return super.onTouchEvent(event);
}
}
thats Game.java
Code:
package com.floland.quaders;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import java.util.Random;
public class Game extends View {
Paint paint = new Paint();
Random rand = new Random();
int t;
int b;
int r;
int l;
public Game(Context context) {
super(context);
}
@Override
public void onDraw(Canvas canvas) {
int t = rand.nextInt(getBottom());
int b = rand.nextInt(getRight());
int r = rand.nextInt(getBottom());
int l = rand.nextInt(getRight());
if (t - b <= 10){
b = b + 10;
}
if (b - t <= 10){
t = t + 10;
}
if (l - r <= 10){
r = r + 10;
}
if (r - l <= 10){
l = l + 10;
}
paint.setColor(Color.BLACK);
paint.setStrokeWidth(0);
canvas.drawRect(l, t, r, b, paint);
//Left Top Right Bottom
Toast.makeText(getContext(), "T= " + t + " B= " + b + " R= " + r + " L= " + l+ " Bott= " + getBottom() + " Rigt= " + getRight() ,Toast.LENGTH_LONG).show();
}
}
I hope you can help me cause im a newbie
thanks
Floland
Related
Hello,
I just started with developing in csharp for my mobile phone. The first project i'm working on is creating a GPS tracker program that will safe the current GPS location to a text file. This file i'll load to a website from where people can download an google earth file (i prefer php programming )
But to get to the point. The program worked fine untill i added some extra functionality (SystemIdleTimerReset and the date in the name of the datafile)
After adding this the program starts in the emulator, however after 30 seconds (when the trigger start for the first time) it comes with the exception (at the red comment):
Exception was unhandeld
The method or operation is not implemented
My code (i added everything from the main form, since i don't know where the error is)
Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Microsoft.WindowsMobile.Samples.Location;
namespace GPS_Tracker
{
public partial class mainform : Form
{
GpsDeviceState device = null;
GpsPosition position = null;
Gps gps = new Gps();
int iTicker = 0;
int iCounter = 0;
string fileName;
private EventHandler updateDataHandler;
private EventHandler timerTicker;
DateTime currentTime = DateTime.Now;
public mainform()
{
InitializeComponent();
}
private void menuExit_Click(object sender, EventArgs e)
{
if (gps.Opened)
{
gps.Close();
}
Close();
}
private void menuStart_Click(object sender, EventArgs e)
{
if (!gps.Opened)
{
gps.Open();
}
menuStart.Enabled = false;
menuStop.Enabled = true;
}
private void menuStop_Click(object sender, EventArgs e)
{
if (gps.Opened)
{
gps.Close();
}
menuStart.Enabled = true;
menuStop.Enabled = false;
}
private void mainform_Load(object sender, EventArgs e)
{
timerTicker = new EventHandler(timerCheck);
updateDataHandler = new EventHandler(UpdateData);
gps.DeviceStateChanged += new DeviceStateChangedEventHandler(gps_DeviceStateChanged);
gps.LocationChanged += new LocationChangedEventHandler(gps_LocationChanged);
Status.Text = "";
}
protected void gps_LocationChanged(object sender, LocationChangedEventArgs args)
{
position = args.Position;
// call the UpdateData method via the updateDataHandler so that we
// update the UI on the UI thread
Invoke(timerTicker);
}
void gps_DeviceStateChanged(object sender, DeviceStateChangedEventArgs args)
{
device = args.DeviceState;
// call the UpdateData method via the updateDataHandler so that we
// update the UI on the UI thread
Invoke(timerTicker);[COLOR="Red"]// place where error comes[/COLOR]
}
void timerCheck(object sender, System.EventArgs args)
{
Invoke(updateDataHandler);
}
void UpdateData(object sender, System.EventArgs args)
{
if (iTicker == 1)
{
SystemIdleTimerReset();
if (gps.Opened)
{
string str = "";
if (device != null)
{
str = device.FriendlyName + " " + device.ServiceState + ", " + device.DeviceState + "\n";
}
if (position != null)
{
iCounter++;
if (position.SeaLevelAltitudeValid &&
position.EllipsoidAltitudeValid &&
position.SpeedValid &&
position.LatitudeValid &&
position.LongitudeValid &&
position.SatellitesInSolutionValid &&
position.SatellitesInViewValid &&
position.SatelliteCountValid &&
position.TimeValid)
{
fileName = "data_" + currentTime.ToString("yyyyMMdd") + ".txt";
StreamWriter output;
output = File.AppendText(fileName);
output.WriteLine(position.SeaLevelAltitude + ";" +
position.EllipsoidAltitude + ";" +
position.SpeedKmh + ";" +
position.Longitude + ";" +
position.Latitude + ";" +
position.GetSatellitesInSolution().Length + "/" +
position.GetSatellitesInView().Length + " (" +
position.SatelliteCount + ";" +
position.Time.ToString());
output.Close();
str += "Saving data to File \nEntry: " + iCounter + "\n";
str += "Current speed: " + position.SpeedKmh + "\n";
str += "Current height: " + position.SeaLevelAltitude + "\n";
}
}
Status.Text = str;
}
iTicker = 0;
}
}
private void SystemIdleTimerReset()
{
throw new Exception("The method or operation is not implemented.");
}
private void Ticker_Tick(object sender, EventArgs e)
{
iTicker = 1;
}
}
}
the error details:
Error details:
System.Exception was unhandled
Message="The method or operation is not implemented."
StackTrace:
at GPS_Tracker.mainform.SystemIdleTimerReset()
at GPS_Tracker.mainform.UpdateData()
at TASK.Invoke()
at System.Windows.Forms.Control._InvokeAll()
at System.Windows.Forms.Control.InvokeHelper()
at System.Windows.Forms.Control.Invoke()
at GPS_Tracker.mainform.timerCheck()
at TASK.Invoke()
at System.Windows.Forms.Control._InvokeAll()
at System.Windows.Forms.Control.WnProc()
at System.Windows.Forms.ContainerControl.WnProc()
at System.Windows.Forms.Form.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at GPS_Tracker.Program.Main()
Click to expand...
Click to collapse
I hope anybody can help me.
Thanks in advance
StruiS
I removed (commented) the SystemIdleTimerReset function and it works again.
Can someone help me implement this function?
Thanks
Have no idea if you guys will know but firstly does the Excalibur support AT commands?
secondly, how would I connect using VC# 2008 Express
code follows
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace phoneBackup
{
public partial class Form1 : Form
{
SerialPort sp = new SerialPort();
public Form1()
{
InitializeComponent();
programStatus.Text = "Connecting...";
}
private void Form1_Load(object sender, EventArgs e)
{
sp.Open();
if (sp.IsOpen == true)
{
programStatus.Text = "Connection: " + sp.IsOpen.ToString();
//status
sp.ReadTimeout = 500;
sp.WriteTimeout = 500;
getStatus();
}
else
{
programStatus.Text = "Not connected, relaunch";
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
textBox1.Text = "";
sp.WriteLine("AT+CGMM");
sp.Write("AT+CGMM");
getStatus();
}
catch (System.Exception ex)
{
textBox1.Text = ex.Message.ToString();
}
}
private void button2_Click(object sender, EventArgs e)
{
try
{
textBox1.Text = "";
textBox1.Text = "Reading..." + Environment.NewLine;
textBox1.Text += "Status: " + Environment.NewLine;
getStatus();
}
catch (Exception ex)
{
textBox1.Text = "error " + ex.Message.ToString();
}
}
private void getStatus()
{
textBox1.Text += "BaseStream: " + sp.BaseStream.ToString() + Environment.NewLine;
textBox1.Text += "BaudRate: " + sp.BaudRate.ToString() + Environment.NewLine;
textBox1.Text += "Bytes to read: " + sp.BytesToRead.ToString() + Environment.NewLine;
textBox1.Text += "Bytes to write: " + sp.BytesToWrite.ToString() + Environment.NewLine;
textBox1.Text += "ReadTimeout: " + sp.ReadTimeout.ToString() + Environment.NewLine;
textBox1.Text += "Port Name: " + sp.PortName.ToString() + Environment.NewLine;
textBox1.Text += "Handshake: " + sp.Handshake.ToString() + Environment.NewLine;
textBox1.Text += "Data bits: " + sp.DataBits.ToString() + Environment.NewLine;
}
private void sp_DataReceived(object sender,
SerialDataReceivedEventArgs e)
{
textBox1.Text += Environment.NewLine + sp.ReadExisting().ToString();
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = "";
getStatus();
}
}
}
Output is
BaseStream: System.IO.Ports.SerialStream
BaudRate: 9600
Bytes to read: 0
Bytes to write: 0
ReadTimeout: 500
Port Name: COM1
Handshake: None
Data bits: 8
no matter which button is pressed
Hello,
I've been trying to do some android stuff on java for some time now, and i've come across a problem here: i can't get the app to execute linux stuff, as there is no system() method like on other platforms... so i searched some code and found this:
Code:
protected void system(String[] Commands){
e Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
DataInputStream osRes = new DataInputStream(process.getInputStream());
Vector<String> res = new Vector<String>();
for (String single : Commands) {
e os.writeBytes(single + "\n");
e os.flush();
e res.add(osRes.readLine());
// Log.e("CMDs", osRes.readLine());
}
e os.writeBytes("exit\n");
e os.flush();
process.waitFor();
}
However that won't work because of some errors i have in the marked lines:
"Unhandled exception type IOException"
and the process.waitFor(); line also gives me an error:
"Unhandled exception type InterruptedException"
Any ideas?
You need to add a try/catch block around that code which catches the IO exception and the interrupted exception.
deleted
So, first of all thanks to both of you it appears to be working now... i tried in on the emulator, and of course "su" didn't work there (broken pipe), so i replaced it by "sh", however this didn't seem to work well too. the application just locked up with a warning in android.... strange...
edit: tried using /system/bin/sh, didn't work, locked up again
What version of Android in the emulator? I've done it with 1.5 through 2.2 in the emulator, just by using "sh".
could you post the code you used please? would be AWESOME!
i'm trying to get this working on 2.1
Sure, I can post some more details later, but for now just the code.
Include the file in your project and use with:
Code:
ShellCommand cmd = new ShellCommand();
CommandResult r = cmd.sh.runWaitFor("ls -l");
if (!r.success()) {
Log.v(TAG, "Error " + r.stderr);
} else {
Log.v(TAG, "Success! " + r.stdout);
}
If you want su you can either use cmd.shOrSu().runWaitFor("..."); which will try su (by running "id", it just tests the status code but it's a nice entry in logcat for debugging) and fallback to sh. Or you can use cmd.su.runWaitFor("...");
Also at
teslacoilsw.com/files/ShellCommand.java
Code:
package com.teslacoilsw.quicksshd;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import android.util.Log;
public class ShellCommand {
private static final String TAG = "ShellCommand.java";
private Boolean can_su;
public SH sh;
public SH su;
public ShellCommand() {
sh = new SH("sh");
su = new SH("su");
}
public boolean canSU() {
return canSU(false);
}
public boolean canSU(boolean force_check) {
if (can_su == null || force_check) {
CommandResult r = su.runWaitFor("id");
StringBuilder out = new StringBuilder();
if (r.stdout != null)
out.append(r.stdout).append(" ; ");
if (r.stderr != null)
out.append(r.stderr);
Log.v(TAG, "canSU() su[" + r.exit_value + "]: " + out);
can_su = r.success();
}
return can_su;
}
public SH suOrSH() {
return canSU() ? su : sh;
}
public class CommandResult {
public final String stdout;
public final String stderr;
public final Integer exit_value;
CommandResult(Integer exit_value_in, String stdout_in, String stderr_in)
{
exit_value = exit_value_in;
stdout = stdout_in;
stderr = stderr_in;
}
CommandResult(Integer exit_value_in) {
this(exit_value_in, null, null);
}
public boolean success() {
return exit_value != null && exit_value == 0;
}
}
public class SH {
private String SHELL = "sh";
public SH(String SHELL_in) {
SHELL = SHELL_in;
}
public Process run(String s) {
Process process = null;
try {
process = Runtime.getRuntime().exec(SHELL);
DataOutputStream toProcess = new DataOutputStream(process.getOutputStream());
toProcess.writeBytes("exec " + s + "\n");
toProcess.flush();
} catch(Exception e) {
Log.e(QuickSSHD.TAG, "Exception while trying to run: '" + s + "' " + e.getMessage());
process = null;
}
return process;
}
private String getStreamLines(InputStream is) {
String out = null;
StringBuffer buffer = null;
DataInputStream dis = new DataInputStream(is);
try {
if (dis.available() > 0) {
buffer = new StringBuffer(dis.readLine());
while(dis.available() > 0)
buffer.append("\n").append(dis.readLine());
}
dis.close();
} catch (Exception ex) {
Log.e(TAG, ex.getMessage());
}
if (buffer != null)
out = buffer.toString();
return out;
}
public CommandResult runWaitFor(String s) {
Process process = run(s);
Integer exit_value = null;
String stdout = null;
String stderr = null;
if (process != null) {
try {
exit_value = process.waitFor();
stdout = getStreamLines(process.getInputStream());
stderr = getStreamLines(process.getErrorStream());
} catch(InterruptedException e) {
Log.e(TAG, "runWaitFor " + e.toString());
} catch(NullPointerException e) {
Log.e(TAG, "runWaitFor " + e.toString());
}
}
return new CommandResult(exit_value, stdout, stderr);
}
}
}
Thanks kevin The code you are using there is awesome Looking good so far, however it keeps returning permission denied... is it some setting in the android manifest?
Actually "Permission denied" often also means "no such file or directory" on android :-/ . It's very frustrating.
Try running something simple to start with like:
cmd.sh.runWaitFor("echo foo");
[email protected] said:
Actually "Permission denied" often also means "no such file or directory" on android :-/ . It's very frustrating.
Try running something simple to start with like:
cmd.sh.runWaitFor("echo foo");
Click to expand...
Click to collapse
yep, i tried running echo as i was confused by the "permission denied" although i had already set write permissions for the sdcard... didn't work, for some odd reason
Hi, I really need help, i want to extract some .png and .jpg from the assets of the app 'Hyperdimension Neptunia The App'
after 3 month of research i found out that the assets are probably "encrypted" i wanted the textures for the live2D model files, and wanted to replace the sounds with the English versions from the iOS app that i extracted.
Audio was .caf in iOS but in Android it says its .mp3
This Line in a class says something about the audio: localEditor.putString("alarm_voice", bw.a(str, "caf", "mp3"));
The .caf opens and runs fine so whats the problem and anyone help me decrypt it? :fingers-crossed:
Full "AlarmActivity.class"
Code:
package jp.co.ideaf.neptune.nepkamijigenapp;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.NumberPicker;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.TimePicker;
import java.util.Calendar;
import java.util.Timer;
import jp.co.ideaf.neptune.nepkamijigenapp.a.a;
import jp.co.ideaf.neptune.nepkamijigenapp.a.d;
import jp.co.ideaf.neptune.nepkamijigenapp.a.f;
import jp.co.ideaf.neptune.nepkamijigenapp.a.h;
import jp.co.ideaf.neptune.nepkamijigenapp.d.z;
public class AlarmActivity extends Activity
{
private a a = null;
private d b = null;
private Timer c = null;
private ee d = null;
private eg e = null;
private Handler f = new Handler();
private LinearLayout g = null;
private static int a(Context paramContext, a parama, long paramLong)
{
h localh = KamijigenApplication.c();
z localz = localh.b(parama.c().f());
int i = localh.a();
String str = localz.g();
Object[] arrayOfObject = new Object[1];
arrayOfObject[0] = Long.valueOf(paramLong / 1000L);
jp.co.ideaf.neptune.nepkamijigenapp.d.k.a(String.format("アラーム発生時間 : %d秒", arrayOfObject), new Object[0]);
f localf = new f(paramLong + Calendar.getInstance().getTimeInMillis());
SharedPreferences.Editor localEditor = paramContext.getSharedPreferences(bw.a(paramContext, 2131034117), 0).edit();
localEditor.putString("alarm_voice", bw.a(str, "caf", "mp3"));
localEditor.putBoolean("snooze", parama.b);
localEditor.putInt("snooze_time", parama.c);
localEditor.commit();
Intent localIntent = new Intent(paramContext, AlarmDialogActivity.class);
localIntent.addFlags(268435456);
PendingIntent localPendingIntent = PendingIntent.getActivity(paramContext, 0, localIntent, 0);
((AlarmManager)paramContext.getSystemService("alarm")).set(0, localf.b(), localPendingIntent);
return i;
}
private void a()
{
TimePicker localTimePicker = (TimePicker)findViewById(2131165202);
if (localTimePicker == null);
while (true)
{
return;
localTimePicker.setIs24HourView(Boolean.valueOf(true));
localTimePicker.setCurrentHour(Integer.valueOf(this.a.c().f()));
localTimePicker.setCurrentMinute(Integer.valueOf(this.a.c().g()));
}
}
private void a(int paramInt)
{
TextView localTextView = (TextView)findViewById(2131165196);
if (localTextView != null)
{
localTextView.setText(Integer.toString(paramInt));
localTextView.append(bw.a(this, 2131034215));
}
}
private void a(int paramInt1, int paramInt2)
{
TextView localTextView1 = (TextView)findViewById(2131165194);
if (localTextView1 != null)
{
localTextView1.setText(Integer.toString(paramInt1));
localTextView1.append(bw.a(this, 2131034211));
}
TextView localTextView2 = (TextView)findViewById(2131165195);
if (localTextView2 != null)
{
localTextView2.setText(Integer.toString(paramInt2));
localTextView2.append(bw.a(this, 2131034212));
}
}
public static void a(Context paramContext, a parama)
{
d locald = KamijigenApplication.a();
locald.b(paramContext, false);
c(paramContext, parama);
parama.a = true;
locald.p().a(parama);
locald.c(paramContext);
}
private void b()
{
CheckBox localCheckBox = (CheckBox)findViewById(2131165197);
if (localCheckBox != null)
{
if (KamijigenApplication.a().p().a)
break label38;
localCheckBox.setEnabled(false);
localCheckBox.setChecked(false);
}
while (true)
{
return;
label38: localCheckBox.setChecked(true);
}
}
private static void c(Context paramContext, a parama)
{
f localf1 = new f(Calendar.getInstance().getTimeInMillis());
int i = localf1.f();
int j = localf1.g();
int k;
int m;
int n;
f localf2;
long l;
if ((i < parama.c().f()) || ((i == parama.c().f()) && (j < parama.c().g())))
{
k = localf1.c();
m = localf1.d();
n = localf1.e();
localf2 = new f(k, m, n, parama.c().f(), parama.c().g(), 0);
jp.co.ideaf.neptune.nepkamijigenapp.d.k.a("targetDate : " + localf2.toString(), new Object[0]);
jp.co.ideaf.neptune.nepkamijigenapp.d.k.a("nowDate : " + localf1.toString(), new Object[0]);
l = localf2.b() - localf1.b();
if (parama.c <= 0)
break label300;
}
label300: for (parama.b = true; ; parama.b = false)
{
int i1 = a(paramContext, parama, l);
parama.c().a(k);
parama.c().b(m);
parama.c().c(n);
parama.d = i1;
return;
f localf3 = new f(86400000L + localf1.b());
k = localf3.c();
m = localf3.d();
n = localf3.e();
localf2 = new f(k, m, n, parama.c().f(), parama.c().g(), 0);
break;
}
}
public void onClickBackButton(View paramView)
{
finish();
}
public void onClickDecideButton(View paramView)
{
CheckBox localCheckBox = (CheckBox)findViewById(2131165197);
if (((RadioButton)findViewById(2131165199)).isChecked())
{
findViewById(2131165201).setVisibility(8);
findViewById(2131165203).setVisibility(0);
findViewById(2131165201).setVisibility(0);
findViewById(2131165203).setVisibility(8);
if (localCheckBox != null)
break label127;
}
while (true)
{
return;
findViewById(2131165201).setVisibility(0);
findViewById(2131165203).setVisibility(8);
findViewById(2131165201).setVisibility(8);
findViewById(2131165203).setVisibility(0);
break;
label127: d locald = KamijigenApplication.a();
if (!locald.p().a)
showDialog(0);
else if ((locald.p().a) && (localCheckBox.isChecked()))
showDialog(2);
else
showDialog(3);
}
}
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
setRequestedOrientation(1);
setContentView(2130903041);
d locald = KamijigenApplication.a();
this.a = new a();
this.a.a(locald.p());
a(this.a.c().f(), this.a.c().g());
a();
b();
TimePicker localTimePicker = (TimePicker)findViewById(2131165202);
if (localTimePicker != null)
{
localTimePicker.setVisibility(0);
localTimePicker.setOnTimeChangedListener(new j(this));
}
userNumberPicker localuserNumberPicker = (userNumberPicker)findViewById(2131165204);
a(this.a.c);
if ((Build.VERSION.SDK_INT < 11) && (localuserNumberPicker != null))
{
localuserNumberPicker.a(0, 59);
localuserNumberPicker.a(this.a.c);
localuserNumberPicker.a(new l(this));
}
if (Build.VERSION.SDK_INT >= 11)
{
FrameLayout localFrameLayout = (FrameLayout)findViewById(2131165203);
localuserNumberPicker.setEnabled(false);
localuserNumberPicker.setVisibility(8);
this.g = new LinearLayout(this);
this.g.setOrientation(0);
NumberPicker localNumberPicker = new NumberPicker(this);
localNumberPicker.setMinValue(0);
localNumberPicker.setMaxValue(59);
localNumberPicker.setValue(this.a.c);
localNumberPicker.setOnValueChangedListener(new m(this));
this.g.addView(localNumberPicker, 0, new LinearLayout.LayoutParams(-2, -2, 1.0F));
localFrameLayout.addView(this.g, new FrameLayout.LayoutParams(-2, -2, 17));
}
findViewById(2131165201).setVisibility(0);
findViewById(2131165203).setVisibility(8);
((RadioGroup)findViewById(2131165198)).setOnCheckedChangeListener(new n(this));
this.b = KamijigenApplication.a();
String str = getResources().getText(2131034115).toString();
LinearLayout localLinearLayout = (LinearLayout)findViewById(2131165191);
Button localButton = (Button)findViewById(2131165205);
if (str.equals(this.b.d(this.b.k())))
{
localLinearLayout.setBackgroundResource(2130837540);
localButton.setBackgroundResource(2130837513);
}
while (true)
{
if (locald.p().a)
showDialog(4);
return;
localLinearLayout.setBackgroundResource(2130837541);
localButton.setBackgroundResource(2130837514);
}
}
protected Dialog onCreateDialog(int paramInt)
{
AlertDialog localAlertDialog;
if (paramInt == 0)
localAlertDialog = new AlertDialog.Builder(this).setTitle(2131034216).setMessage(2131034217).setPositiveButton(2131034218, new q(this)).setNegativeButton(2131034219, null).create();
while (true)
{
return localAlertDialog;
if (paramInt == 1)
{
localAlertDialog = new AlertDialog.Builder(this).setMessage(2131034220).setPositiveButton(2131034221, new r(this)).create();
}
else if (paramInt == 2)
{
localAlertDialog = new AlertDialog.Builder(this).setTitle(2131034222).setMessage(2131034223).setPositiveButton(2131034224, new s(this)).setNegativeButton(2131034225, null).create();
}
else if (paramInt == 3)
{
localAlertDialog = new AlertDialog.Builder(this).setTitle(2131034226).setMessage(2131034227).setPositiveButton(2131034228, new t(this)).setNegativeButton(2131034229, null).create();
}
else
{
localAlertDialog = null;
if (paramInt == 4)
localAlertDialog = new AlertDialog.Builder(this).setMessage(2131034304).setPositiveButton(2131034228, new k(this)).setNegativeButton(2131034229, null).create();
}
}
}
protected void onPause()
{
super.onPause();
if (this.d != null)
this.d.b();
this.c.cancel();
this.c.purge();
}
protected void onResume()
{
super.onResume();
this.d = new ee(this);
this.d.a();
this.c = new Timer(true);
this.c.scheduleAtFixedRate(new o(this), 100L, 100L);
Display localDisplay = ((WindowManager)getSystemService("window")).getDefaultDisplay();
if (localDisplay.getWidth() > localDisplay.getHeight());
for (int i = localDisplay.getHeight(); ; i = localDisplay.getWidth())
{
float f1 = i / 480.0F;
LinearLayout localLinearLayout = (LinearLayout)findViewById(2131165193);
getResources().getDrawable(2130837742);
localLinearLayout.getLayoutParams().height = ((int)(90.0F * f1));
localLinearLayout.getLayoutParams().width = ((int)(f1 * 172.0F));
localLinearLayout.requestLayout();
this.e = new eg(this, 0);
return;
}
}
}
well if it is encrypted, what type ? and if it\s something like AES CBC how do you intend to get the cypher ?
That's the problem, im kinda new to this thing so im not sure how to get the cypher and i think its AES encrypted but not 100% certain. Sorry for being a noob.
I've made a class called SendToWear with a static method called sendMessage(Context context, String path, @nullable String data) which finds all connected nodes and sends data to any found nodes.
This class is identical to another class I used in an Android Wear device called SendToPhone which works successfully and will send a fire-and-forget message to my connected mobile phone, but SendToWear (a class with identical code, as stated) will not.
The problem is at this section:
Code:
GoogleApiClient sClient = new GoogleApiClient.Builder(context)
.addApi(Wearable.API)
.build();
ConnectionResult connectionResult =
sClient.blockingConnect(5, TimeUnit.SECONDS);
if (!connectionResult.isSuccess()) {
Log.e(TAG, "Failed to connect to sClient.");
return 0;
} else Log.d(TAG, "sClient connected!");
The handheld device always return 'Failed to connect to sClient'. Can anybody explain this?
Thanks.
Full code below:
Code:
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.wearable.MessageApi;
import com.google.android.gms.wearable.Node;
import com.google.android.gms.wearable.NodeApi;
import com.google.android.gms.wearable.Wearable;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
public class SendToPhone {
public static int sendMessage(Context context, String path, [user=3869344]@nullable[/user] String data){
Log.d(TAG, "Path: " + path + "\tData: " + data);
ArrayList<String> nodes;
int sent; // amount of nodes which received the message
if(context == null || path == null){
Log.d(TAG, "Context or Path is null.");
return 0;
}
GoogleApiClient sClient = new GoogleApiClient.Builder(context)
.addApi(Wearable.API)
.build();
ConnectionResult connectionResult =
sClient.blockingConnect(5, TimeUnit.SECONDS);
if (!connectionResult.isSuccess()) {
Log.e(TAG, "Failed to connect to sClient.");
return 0;
} else Log.d(TAG, "sClient connected!");
nodes = getNodes(sClient);
if(nodes.size() == 0) return 0;
for(int i = sent = 0; i < nodes.size(); i++) {
MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(
sClient, nodes.get(i), path, data.getBytes()).await();
// was not able to send message
if(result.getStatus().isSuccess())
++sent;
}
sClient.disconnect();
Log.d(TAG, "SENT: " + sent);
return sent;
}
private static ArrayList<String> getNodes(GoogleApiClient client) {
ArrayList<String> results = new ArrayList<String>();
NodeApi.GetConnectedNodesResult nodes =
Wearable.NodeApi.getConnectedNodes(client).await(3, TimeUnit.SECONDS);
if(nodes == null || !nodes.getStatus().isSuccess())
return results;
for (Node node : nodes.getNodes()) {
results.add(node.getId());
}
return results;
}
}