15,893,790 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 11420908 (Top 18 by date)
Member 11420908
17-Jul-15 7:02am
View
i am already removed the semicolon
Member 11420908
19-Jun-15 0:45am
View
This is my Code
public class MainActivity extends ActionBarActivity {
String n="";
Timer timer;
TimerTask timerTask;
final android.os.Handler handler = new android.os.Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startTimer();
Test2();
}
public void startTimer() {
// Pull();
//set a new Timer
timer = new Timer();
//initialize the TimerTask's job
initializeTimerTask();
//schedule the timer, after the first 5000ms the TimerTask will run every 10000ms
timer.schedule(timerTask,0, 15000); //
}
public void Timer15()
{
timer =new Timer();
initializeTimerTask();
timer.schedule(timerTask,0,5000);
}
public void initializeTimerTask() {
timerTask = new TimerTask() {
public void run() {
//use a handler to run a toast that shows the current timestamp
handler.post(new Runnable() {
public void run() {
Test1();
// Toast.makeText(getApplicationContext(),"hai",Toast.LENGTH_SHORT).show();
}
});
}
};
}
public void Test1()
{
n="vetri";
}
public void Test2()
{
if (n=="vetri")
{
timer.cancel();
Timer15();
Toast.makeText(getApplicationContext(),n,Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(),"Error",Toast.LENGTH_LONG).show();
}
}
}
Member 11420908
19-Jun-15 0:44am
View
This is my Code
public class MainActivity extends ActionBarActivity {
String n="";
Timer timer;
TimerTask timerTask;
final android.os.Handler handler = new android.os.Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startTimer();
Test2();
}
public void startTimer() {
// Pull();
//set a new Timer
timer = new Timer();
//initialize the TimerTask's job
initializeTimerTask();
//schedule the timer, after the first 5000ms the TimerTask will run every 10000ms
timer.schedule(timerTask,0, 15000); //
}
public void Timer15()
{
timer =new Timer();
initializeTimerTask();
timer.schedule(timerTask,0,5000);
}
public void initializeTimerTask() {
timerTask = new TimerTask() {
public void run() {
//use a handler to run a toast that shows the current timestamp
handler.post(new Runnable() {
public void run() {
Test1();
// Toast.makeText(getApplicationContext(),"hai",Toast.LENGTH_SHORT).show();
}
});
}
};
}
public void Test1()
{
n="vetri";
}
public void Test2()
{
if (n=="vetri")
{
timer.cancel();
Timer15();
Toast.makeText(getApplicationContext(),n,Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(),"Error",Toast.LENGTH_LONG).show();
}
}
}
Member 11420908
16-May-15 6:43am
View
okay thanks
Member 11420908
16-May-15 5:57am
View
How can i solve this problem
Member 11420908
11-May-15 6:33am
View
this is my seed value :
String seedValue = "MAKV2SPBNI99212";
Member 11420908
8-May-15 6:55am
View
This is my code
public class MainActivity extends ActionBarActivity {
String seedValue = "MAKV2SPBNI99212";
String device,json;
String DeviceID = "490154203237518";
String ControllerDeviceID = "Null";
String PartnerMode = "None";
String PhoneModel="Samsung";
String PhoneNumber = "8056792232";
String PhoneOS = "Lollypop";
String CreatedOn = "15.02.1201";
String Status = "Active";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//// String seedValue = "MAKV2SPBNI99212";
// String normalText = "VIJAY";
// String normalTextEnc;
//// String Json="";
JSONObject jsonObject = new JSONObject();
try {
JSONObject jsonObject1=new JSONObject();
jsonObject1.accumulate("DeviceId",DeviceID);
jsonObject1.accumulate("ControllerDeviceID",ControllerDeviceID);
jsonObject1.accumulate("PartnerMode",PartnerMode);
jsonObject1.accumulate("PhoneModel",PhoneModel);
jsonObject1.accumulate("PhoneNumber",PhoneNumber);
jsonObject1.accumulate("PhoneOS",PhoneOS);
jsonObject1.accumulate("CreatedOn",CreatedOn);
jsonObject1.accumulate("Status",Status);
json=jsonObject1.toString();
} catch (JSONException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
try {
device = AESHelper.encrypt(seedValue,json);
String normalTextDec = AESHelper.decrypt(seedValue,device);
TextView txe=(TextView)findViewById(R.id.textView);
txe.setTextSize(14);
txe.setText("Normal Text ::"+json +" \n Encrypted Value :: "+device +" \n Decrypted value :: "+normalTextDec);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Encryption ex=new Encryption();
ex.execute();
}
class Encryption extends AsyncTask
{
@Override
protected Object doInBackground(Object[] params) {
Httpt();
return null;
}
public void Httpt()
{
HttpPost httpPost1=new HttpPost("http://kredo.no-ip.org/SSMA/api/DevicesAPI/RegisterDevice?device="+device);
try {
HttpClient httpClient=new DefaultHttpClient();
HttpResponse response=httpClient.execute(httpPost1);
HttpEntity entity = response.getEntity();
String responseBody = EntityUtils.toString(entity); //To receive response from server
Log.v("response", responseBody.toString());
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Member 11420908
6-May-15 6:13am
View
hi,
i just want to create a app that send device imei number and phone model to particular url thats all.
Member 11420908
6-May-15 6:11am
View
nothing happen when run.
i'd like to know my data are sent or not to the url
Member 11420908
6-May-15 6:07am
View
No
Member 11420908
6-May-15 6:07am
View
i want post values to the url
Member 11420908
6-May-15 6:05am
View
No
Member 11420908
4-May-15 2:18am
View
Hi
i have test the all code with break point it't throw any exception during debug but when i run the code it shows java.net.unknownexception
Member 11420908
4-May-15 1:30am
View
hi i just trying to show details from url in a textview by sollwing method.
whenever i run the code it throw a exception "java.net.UnknownHostException"
the code is:
class Apical extends AsyncTask
{
@Override
protected Object doInBackground(Object[] params) {
TextView textv = (TextView)findViewById(R.id.txt1);
textv.setText("Text Has Been Changed");
BufferedReader in = null;
String data = null;
try{
HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet();
URI website = new URI("
http://kredo.no-ip.org/SSMA/api/DevicesAPI/GetDevices
");
request.setURI(website);
HttpResponse response = httpclient.execute(request);
in = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
// NEW CODE
String line = in.readLine();
textv.append(" First line: " + line);
// END OF NEW CODE
textv.append(" Connected ");
}catch(Exception e){
Log.e("log_tag", "Error in http connection " + e.toString());
}
return null;
}
}
Member 11420908
4-May-15 1:21am
View
This is my code.
TextView textv = (TextView)findViewById(R.id.txt1);
// webView=(WebView)findViewById(R.id.webView);
// webView.loadUrl("http://kredo.no-ip.org/SSMA/api/DevicesAPI/GetDevices");
textv.setText("Text Has Been Changed");
BufferedReader in = null;
String data = null;
try{
HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet();
URI website = new URI("http://kredo.no-ip.org/SSMA/api/DevicesAPI/GetDevices");
request.setURI(website);
HttpResponse response = httpclient.execute(request);
in = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
// NEW CODE
String line = in.readLine();
textv.append(" First line: " + line);
// END OF NEW CODE
textv.append(" Connected ");
}catch(Exception e){
Log.e("log_tag", "Error in http connection " + e.toString());
}
Member 11420908
22-Apr-15 6:17am
View
+++++++++.NET+++++++++++++
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace WebApi.Controllers
{
public class DefaultController : ApiController
{
Database2Entities db=new Database2Entities();
// GET: api/Default
public IEnumerable<device> Get()
{
return db.Devices.AsEnumerable();
}
// GET: api/Default/5
public Device Get(int id)
{
return db.Devices.Where(x => x.Id == id).FirstOrDefault();
}
// POST: api/Default
public Device Post([FromBody]int id,int imei,int btrylevel)
{
Device device = new Device()
{
Id = id,
btrylevel = btrylevel,
imei = imei
};
db.Devices.Add(device);
db.SaveChanges();
return device;
}
// PUT: api/Default/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE: api/Default/5
public void Delete(int id)
{
}
}
}
Member 11420908
22-Apr-15 6:10am
View
i just created app that detect device imei number and battery level.
in .net i crated a simple web api which shows details from database as xml file in we browser.
++++android+++
package com.example.vetriselvanv.im;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.telephony.TelephonyManager;
import android.widget.TextView;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends ActionBarActivity {
TextView textView, textView3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
textView = (TextView) findViewById(R.id.textView);
String string = tm.getDeviceId();
textView.setText("IMEI NUMBER IS" + string + "fhkj");
textView3 = (TextView) this.findViewById(R.id.textView3);
btrylevel();
postData();
}
private void btrylevel() {
BroadcastReceiver batteryLevelReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
context.unregisterReceiver(this);
int rawlevel = intent.getIntExtra("level", -1);
int scale = intent.getIntExtra("scale", -1);
int level = -1;
if (rawlevel >= 0 && scale > 0) {
level = (rawlevel * 100) / scale;
}
textView3.setText("Battery Level: " + level + "%");
}
};
IntentFilter batteryLevelFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
registerReceiver(batteryLevelReceiver, batteryLevelFilter);
}
public void postData() {
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
textView = (TextView) findViewById(R.id.textView);
final String string = tm.getDeviceId();
textView.setText(string);
textView3 = (TextView) this.findViewById(R.id.textView3);
btrylevel();
// Create a new HttpClient and Post Header
final HttpClient httpclient = new DefaultHttpClient();
final HttpPost httppost = new HttpPost("http://localhost:50554/api/Default");
BroadcastReceiver batteryLevelReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
context.unregisterReceiver(this);
int rawlevel = intent.getIntExtra("level", -1);
int scale = intent.getIntExtra("scale", -1);
int level = -1;
if (rawlevel >= 0 && scale > 0) {
level = (rawlevel * 100) / scale;
}
textView3.setText("Battery Level: " + level + "%");
try {
// Add your data
List<namevaluepair> nameValuePairs = new ArrayList<namevaluepair>(3);
nameValuePairs.add(new BasicNameValuePair("Id", "5"));
nameValuePairs.add(new BasicNameValuePair("btrylevel", textView3.toString()));
nameValuePairs.add(new BasicNameValuePair("imei", string));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute H
Member 11420908
22-Apr-15 2:11am
View
i am the new for android so please tell me detailed in .net and android.
Show More