public
class
test
extends
AppCompatActivity {
String chapter;
String pnum=
null
;
String baseimg=
null
;
String answer=
null
;
String[] arraytext;
Object xx;
TextView tv;
ImageView img;
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.test);
tv = (TextView) findViewById(R.id.textView);
img = (ImageView) findViewById(R.id.imageView);
getproblem task =
new
getproblem();
task.execute();
try
{
String tt = xx.toString();
arraytext = tt.split(
";"
);
answer = getStr(arraytext[
0
]);
baseimg = getStr(arraytext[
1
]);
pnum = getStr(arraytext[
2
]);
byte
[] imgte = Base64.decode(baseimg);
Bitmap putimg = byteArrayToBitmap(imgte);
img.setImageBitmap(putimg);
}
catch
(Exception e)
{
tv.setText(e.getStackTrace().toString());
}
}
public
Bitmap byteArrayToBitmap(
byte
[] $byteArray ) {
Bitmap bitmap = BitmapFactory.decodeByteArray( $byteArray,
0
, $byteArray.length ) ;
return
bitmap ;
}
public
String getStr(String x)
{
int
index=x.indexOf(
"="
);
int
indexend=x.length();
String answer=x.substring(index+
1
,indexend);
return
answer;
}
public
void
GoNext(View v)
{
}
public
class
getproblem
extends
AsyncTask<String,String,String> {
@Override
protected
String doInBackground(String...params)
{
request.addProperty(
"unit"
,
1
);
SoapSerializationEnvelope envelope =
new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet=
true
;
try
{
Object result=envelope.getResponse();
xx=result;
String w=xx.toString();
return
xx.toString();
}
catch
(Exception e)
{
e.printStackTrace();
return
e.toString();
}
}
protected
void
onPostExecute(String result)
{
super
.onPostExecute(result);
tv.setText(result);
}
}