Here is my service class
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
public class Communicationservice extends Service {
#Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
#Override
public void onCreate() {
super.onCreate();
Log.d("I AM Service","Service Created");
}
#Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
}
}
Here is my Main Activity
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("flow","1");
Intent in = new Intent("com.yal.Communication.Communicationservice");
this.startService(in);
//startService(new Intent(MainActivity.this,Communicationservice.class));
Log.d("flow","2");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Here is Mainfest.xml
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity > ... </activity>
<service android:enabled="true" android:name="com.yal.Communication.Communicationservice"></service>
</application>
Error
11-02 16:34:17.939: D/flow(1390): 1
11-02 16:34:17.939: W/ActivityManager(92): Unable to start service Intent { act=com.yal.Communication.Communicationservice }: not found
11-02 16:34:17.939: D/flow(1390): 2
you need to check Intent-Filter.
below snippet will help you.
<service android:name="com.yal.Communication.Communicationservice">
<intent-filter>
<action android:name="com.yal.Communication.Communicationservice" />
</intent-filter>
</service>
Then you can call this services like follows.
Intent serviceIntent = new Intent("com.yal.Communication.Communicationservice");
startService(serviceIntent);
Constructor public Intent (String action) can be used to specify action only see following java doc:
public Intent (String action)
Create an intent with a given action. All other fields (data, type, class) are null. Note that the action must be in a namespace because Intents are used globally in the system -- for example the system VIEW action is android.intent.action.VIEW; an application's custom action would be something like com.google.app.myapp.CUSTOM_ACTION.
Parameters
action The Intent action, such as ACTION_VIEW.
make following change to you intent creation:
Intent in = new Intent(this,com.yal.Communication.Communicationservice.class);
Or specify the action in the me manifest file:
<service android:name="com.yal.Communication.Communicationservice">
<intent-filter>
<action android:name="com.yal.Communication.Communicationservice" />
</intent-filter>
</service>
Related
I would like to visible my application view above the keyboard whenever the user clicks on textView in any application, the only thing that I knew is my application should be running in background and make the view visible when keyboard gets called, but I'm not sure if that's possible and if it's, I don't know how to do that.
I hope that helps you to get what I'm talking about
Edit 8/5/2016:
I create a foreground service but I don't know how to detect soft keyboard in the other apps
MainActivity.java
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent SERVICE_INTENT = new Intent(this,MyServiceTest.class);
startService(SERVICE_INTENT);
}
}
MyServiceTest.java
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
public class MyServiceTest extends Service {
#Override
public void onCreate() {
super.onCreate();
Intent MAIN_INTENT = new Intent(this,MainActivity.class);
PendingIntent myPendingIntent = PendingIntent.getActivity(this,0,MAIN_INTENT,0);
Notification myNotification = new Notification.Builder(this).setContentTitle("Title")
.setContentText("The Content text").setSmallIcon(R.mipmap.ic_launcher)
.setWhen(System.currentTimeMillis()).setContentIntent(myPendingIntent)
.build();
startForeground(1337,myNotification);
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
Thread myThread = new Thread(new Runnable() {
#Override
public void run() {
}
});
myThread.start();
return START_STICKY;
}
#Override
public void onDestroy() {
super.onDestroy();
}
#Nullable
#Override
public IBinder onBind(Intent intent) {
return null;
}
}
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".MyServiceTest">
</service>
</application>
Any information or idea could be helpful, Thanks in advance ^_^
I believe this is what you want:
android:windowSoftInputMode="stateHidden|adjustPan"
Add it to your activity in your manifest.
Example:
<activity
android:name="activities.WorkObjectActivity"
android:windowSoftInputMode="stateHidden|adjustPan"//This one
android:label="#string/urenToevoegen"
android:screenOrientation="portrait"
android:parentActivityName="activities.MainActivity"/>
My Requirment
I am trying to build an application which shows a Toast whenever user makes a outgoing call from the phone. For this I am using a BroadcastReceiver to tap the call action and a service (to run Receiver always). once I start this activity, it starts showing toast when a outgoing call get initiated ...everything works well.
Issues
Sometimes I dont get any Toast Action EVEN for Outgoing call as well, is that mean service stops after some time ?
After phone reboot Toast Action for Outgoing call stops. Untill you start the servce again manually.
The code I have written is ok ? OR can it be improved ?
Below is the complete code -
MainActivity.class
public class MainActivity extends Activity
{
CallNotifierService m_service;
boolean isBound = false;
private ServiceConnection m_serviceConnection = new ServiceConnection()
{
#Override
public void onServiceConnected(ComponentName className, IBinder service)
{
m_service = ((CallNotifierService.MyBinder)service).getService();
Toast.makeText(MainActivity.this, "Service Connected", Toast.LENGTH_LONG).show();
isBound = true;
Intent intent = new Intent(MainActivity.this, CallNotifierService.class);
startService(intent);
}
#Override
public void onServiceDisconnected(ComponentName className)
{
m_service = null;
isBound = false;
}
};
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this, CallNotifierService.class);
bindService(intent, m_serviceConnection, Context.BIND_AUTO_CREATE);
}
.
.
.
}
CallNotifierService.class
public class CallNotifierService extends Service
{
private final IBinder myBinder = new MyBinder();
private static final String ACTION_OUTGOING_CALL = "android.intent.action.NEW_OUTGOING_CALL";
private static final String ACTION_ANSWER = "android.intent.action.ANSWER";
private static final String ACTION_CALL = "android.intent.action.CALL";
private CallBr br_call;
#Override
public IBinder onBind(Intent arg0)
{
return myBinder;
}
#Override
public void onDestroy()
{
Log.d("service", "destroy");
this.unregisterReceiver(this.br_call);
Toast.makeText(CallNotifierService.this, "Receiver Un-Registered", Toast.LENGTH_LONG).show();
super.onDestroy();
}
#Override
public int onStartCommand(Intent intent, int flags, int startId)
{
final IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_ANSWER);
filter.addAction(ACTION_CALL);
filter.addAction(ACTION_OUTGOING_CALL);
this.br_call = new CallBr();
this.registerReceiver(this.br_call, filter);
Toast.makeText(CallNotifierService.this, "onStartCommand Called", Toast.LENGTH_LONG).show();
return START_STICKY;
}
public class MyBinder extends Binder
{
CallNotifierService getService()
{
return CallNotifierService.this;
}
}
public class CallBr extends BroadcastReceiver
{
public CallBr() {}
#Override
public void onReceive(Context context, Intent intent)
{
Toast.makeText(context, "Action:"+intent.getAction(), Toast.LENGTH_LONG).show();
}
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alwaysrunningprocesswithcallanswertap"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-sdk
android:minSdkVersion="22"
android:targetSdkVersion="22" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.example.alwaysrunningprocesswithcallanswertap.CallNotifierService" />
</application>
</manifest>
Could anyone please help for the issue OR pointout something better ?
#Bharat Once device switch off automatically service will stop, So when ever your device reboot that time you need to start service again then only you will get Toast Action, refer this example code :
BootCompleteReceiver.java
package com.example.newbootservice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class BootCompleteReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Intent service = new Intent(context, AutostartService.class);
context.startService(service);
}
}
AutostartService .java
package com.example.newbootservice;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class AutostartService extends Service {
#Override
public void onCreate() {
super.onCreate();
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
return Service.START_STICKY;
}
#Override
public void onDestroy() {
super.onDestroy();
Toast.makeText(this, "Service Destroy", Toast.LENGTH_LONG).show();
}
#Override
public IBinder onBind(Intent arg0) {
return null;
}
}
MainActivity.java
package com.example.newbootservice;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startService(new Intent(getBaseContext(), AutostartService.class));
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.newbootservice"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<service android:name=".AutostartService"/>
<receiver android:name=".BootCompleteReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I am going to write an application using google play services activity recognition api. the training in android developer site was straight forward but in the past couple of hours i wrote a simple application but i can't get any result from it.
UPDATE : Actually i am going to show the current activity of user in 5 second intervals as a toast message (as you can see in OnIntentHandler method in ActivityRecognitionService Intent Servie) . i think something is wrong with the calling the Intent because as you can see in my code the toast that says the ActivityRecognitionClient is connected on OnConnected method.
did i miss something ?
Thanks in advance.
Manifest File :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nikapps.activityrecognition"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission
android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<service
android:name="com.nikapps.activityrecognition.ActivityRecognitionService"
android:label="#string/app_name"
android:exported="false">
</service>
<activity
android:name="com.nikapps.activityrecognition.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.java
package com.nikapps.activityrecognition;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
import com.google.android.gms.location.ActivityRecognitionClient;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.Toast;
public class MainActivity extends FragmentActivity implements ConnectionCallbacks, OnConnectionFailedListener{
public static int intervals = 5000;
private PendingIntent pendingIntent;
private ActivityRecognitionClient activityRecognition;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activityRecognition = new ActivityRecognitionClient(this, this, this);
activityRecognition.connect();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public void onConnectionFailed(ConnectionResult result) {
// TODO Auto-generated method stub
}
#Override
public void onConnected(Bundle connectionHint) {
// TODO Auto-generated method stub
Toast.makeText(this, "connected", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this, ActivityRecognitionService.class);
pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
activityRecognition.requestActivityUpdates(0, pendingIntent);
}
#Override
public void onDisconnected() {
// TODO Auto-generated method stub
Toast.makeText(this, "disconnected", Toast.LENGTH_SHORT).show();
}
}
ActivityRecognitionService.java
package com.nikapps.activityrecognition;
import com.google.android.gms.location.ActivityRecognitionResult;
import com.google.android.gms.location.DetectedActivity;
import android.app.IntentService;
import android.content.Intent;
import android.widget.Toast;
public class ActivityRecognitionService extends IntentService{
public ActivityRecognitionService() {
super("ActivityRecognitionService");
Toast.makeText(this, "here", Toast.LENGTH_SHORT).show();
// TODO Auto-generated constructor stub
}
#Override
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
Toast.makeText(this, "here2", Toast.LENGTH_SHORT).show();
ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
DetectedActivity activity = result.getMostProbableActivity();
int type = activity.getType();
Toast.makeText(this, getNameFromType(type), Toast.LENGTH_SHORT).show();
}
private String getNameFromType(int activityType) {
switch(activityType) {
case DetectedActivity.IN_VEHICLE:
return "in_vehicle";
case DetectedActivity.ON_BICYCLE:
return "on_bicycle";
case DetectedActivity.ON_FOOT:
return "on_foot";
case DetectedActivity.STILL:
return "still";
case DetectedActivity.UNKNOWN:
return "unknown";
case DetectedActivity.TILTING:
return "tilting";
}
return "unknown";
}
}
You can broadcast an intent to send messages from the service to the main class
For example, use the following in your ActivityRecognitionService.java:
Intent mIntent = new Intent("myCustomIntentMessage")
.putExtra("ActivityType", getNameFromType(type));
getLocalBroadcast().sendBroadcast(mIntent);
Then you just need to register the broadcast receiver for "myCustomIntentMessage" on your MainActivity.java and put the Toast message code in the broadcast receiver OnReceive event.
You can only call the Toast from a thread that has a handler/Looper set up. To achieve what you're envisioning you have two options
Use a broadcast from the IntentService and have an activity that has a BroadcastReceiver that shows the UI. This way, the toast is not shown when the activity is not in the foreground . register/unregister the receiver in your onResume()/onPause()
create a handler and call your method in Handler.post(new Runnable() {.. })
Error calling toast from Service Android
I made a service that every 5 second he put on the screen a TAG (I think this is the name of this). When I make a boot it needs to put the TAG on the screen but he says that the app crashed. Why?
The code:
Android Manifest:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<receiver android:name="com.YuvalFatal.MyBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:enabled="true" android:name="com.YuvalFatal.MyService"/>
BroadcastReceiver:
package com.YuvalFatal.ineedhelp;
import java.util.Timer;
import java.util.TimerTask;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class MyBroadcastreceiver extends BroadcastReceiver {
#Override
public void onReceive(final Context arg0, Intent arg1) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
Intent startServiceIntent = new Intent(arg0, MyService.class);
arg0.startService(startServiceIntent);
}
}, 0, 5000);
}
}
IntentService:
package com.YuvalFatal.ineedhelp;
import android.app.IntentService;
import android.content.Intent;
import android.util.Log;
public class MyService extends IntentService {
private static final String TAG = "com.YuvalFatal.ineedhelp";
public MyService(String name) {
super(name);
// TODO Auto-generated constructor stub
}
#Override
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
Log.i(TAG, "Intent Service started");
}
}
I think (yep, I am magician and have great intuition :) your Service constructor should be default:
public class MyService extends IntentService {
...
public MyService() { // Default constructor! Without params!
super("MyService"); // Or another string
}
...
}
Other code looks normal
I am trying to broadcast a toast message with the following code extending Activity. But the broadcast is not received by another Activity, the toast is not displayed. Can someone solve my error? The main activity is SendBroadcast.java
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class SendBroadcast extends Activity {
public static String BROADCAST_ACTION =
"com.unitedcoders.android.broadcasttest.SHOWTOAST";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void sendBroadcast(View v) {
Intent broadcast = new Intent();
broadcast.setAction(BROADCAST_ACTION);
sendBroadcast(broadcast);
}
}
Toast Display Activity is ToastDisplay.java
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.widget.Toast;
public class ToastDisplay extends Activity {
private BroadcastReceiver receiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(getApplicationContext(), "received",
Toast.LENGTH_SHORT).show();
}
};
#Override
protected void onResume() {
IntentFilter filter = new IntentFilter();
filter.addAction(SendBroadcast.BROADCAST_ACTION);
registerReceiver(receiver, filter);
super.onResume();
}
#Override
protected void onPause() {
unregisterReceiver(receiver);
super.onPause();
}
}
and manifest.xml is as follows
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.broad"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".SendBroadcast"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".ToastReceiver" >
<intent-filter>
<action android:name="com.unitedcoders.android.broadcasttest.SHOWTOAST" />
</intent-filter>
</receiver>
</application>
</manifest>
There can be two types of broacast: static and dynamic. Static are those that are declared in the manifest file. Dynamic can be declared during runtime. You combined these two types of broadcast in one broadcast.
To declare a simple dynamic broadcast you can use the following code (that is based on your code). It will simply display toast message when activity is shown.
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
public class BroadcastTestActivity extends Activity {
public static String BROADCAST_ACTION =
"com.unitedcoders.android.broadcasttest.SHOWTOAST";
BroadcastReceiver br = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
Log.w("Check", "Inside On Receiver");
Toast.makeText(getApplicationContext(), "received",
Toast.LENGTH_SHORT).show();
}
};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
IntentFilter filter = new IntentFilter();
filter.addAction(BROADCAST_ACTION);
filter.addCategory(Intent.CATEGORY_DEFAULT);
registerReceiver(br, filter);
}
#Override
protected void onResume() {
super.onResume();
sendBroadcast();
}
#Override
protected void onPause() {
super.onPause();
unregisterReceiver(br);
}
public void sendBroadcast() {
Intent broadcast = new Intent();
broadcast.setAction(BROADCAST_ACTION);
broadcast.addCategory(Intent.CATEGORY_DEFAULT);
sendBroadcast(broadcast);
}
}
So now instead of showing toast you can call your new activity. The following actions depend on your needs (what you want to do).
Where is ToastReceiver class?
<receiver android:name=".ToastReceiver">
<intent-filter>
<action android:name="com.unitedcoders.android.broadcasttest.SHOWTOAST"/>
</intent-filter>
</receiver>`
Change
public class ToastDisplay extends Activity {
private BroadcastReceiver receiver = new BroadcastReceiver() {
}
to
public class ToastReceiver extends BroadcastReceiver {
}
Try
<activity android:name=".SendBroadcast" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BROADCAST" />
</intent-filter>
</activity>
In onCreate() call
sendBroadcast(v);
Button b1 = (Button)findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
try {
String RESULT = new TestAsyncTask().execute(" ").get();
System.out.println("RESULT "+RESULT);
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});