onActivityResult not being called - android

KitActivity:
/** in KitActivity, handler invoked after successful transmission **/
private final Handler txHandle = new Handler() {
#Override
public void handleMessage(Message msg) {
boolean success = msg.getData().getBoolean("success");
dismissDialog(DIALOG_TX_PROGRESS);
if(success) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt("previous_scale", mScaleSpn.getSelectedItemPosition());
editor.commit();
//clearFields();
//showDialog(DIALOG_ETX);
KitActivity.this.setResult(0);
KitActivity.this.finish();
} else {
removeDialog(DIALOG_FAIL);
showDialog(DIALOG_FAIL);
}
}
};
MainActivity:
/** in the MainActivity **/
public void startCreateKit() {
Intent i = new Intent(MainActivity.this, KitActivity.class);
startActivityForResult(i,0);
}
protected void onActivityResult(int reqCode, int resCode) {
if(reqCode==0) {
if(resCode==0) {
//we good, perform sync
showDialog(DIALOG_TX_PROGRESS);
Toast.makeText(this, "Performing Auto Sync", Toast.LENGTH_LONG).show();
updateKits();
} else {
//uh oh
}
}
}
createKitBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//Toast.makeText(context, "NEW KIT", Toast.LENGTH_SHORT).show();
startCreateKit();
}
});
onActivityResult is never called in MainActivity. this is pretty much by the book. what's the issue?
stuff i've tried:
- using Activity.RESULT_OK for the result code (which translates to -1);
- removing the setResult() and finish() calls from the handler and calling an outside method to invoke them.
i don't see anything wrong. here's the manifest, nothing awry here:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.conceptualsystems.kitmobile"
android:versionCode="8"
android:versionName="#string/version">
<application android:label="#string/app_name" android:icon="#drawable/icon" android:debuggable="true">
<activity android:name="MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ShipActivity"
android:label="Ship Kits"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation">
</activity>
<activity android:name="KitActivity"
android:label="Kit Entry"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation">
</activity>
<activity android:name="ColorActivity"
android:label="Color Selection"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation">
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
what gives?

in the activity you start (KitActivity.class) on success you do this
Intent intent = this.getIntent();
intent.putExtra("SOMETHING", "EXTRAS");
this.setResult(RESULT_OK, intent);
finish();
else you put RESULT_CANCELED instead of RESULT_OK

replaced:
protected void onActivityResult(int reqCode, int resCode)
with:
protected void onActivityResult(int reqCode, int resCode, Intent intent)
amazing what happens when you review the documentation... -_-

Related

Cannot activate my custom permission in my code

I want to ask users to agree with the disclaimer that I have provided in my application, and then if they agreed, next time they are using the app, we just re-show them the disclaimer for a few seconds without asking to click on anything and redirect them to the application. The best way I could have come up with it was, using a custom permission and however I did add permission commands to my manifest I could not figure out how to actually activate the permission in my code:
import java.util.jar.Manifest;
public class Language extends Activity {
Button engBut, fraBut;
// public static int j;
public void click (View view){
// j=1;
Intent intent = new Intent(getApplicationContext(),MainActivity.class);
startActivity(intent);
}
public void fraClick (View view){
// j=2;
Intent intent = new Intent(getApplicationContext(),MainActivity.class);
startActivity(intent);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_language);
ImageView logo = (ImageView) findViewById(R.id.logo);
ImageView montfortLogo = (ImageView) findViewById(R.id.montfortLogo);
montfortLogo.setImageResource(R.drawable.k);
logo.setImageResource(R.drawable.j);
engBut = (Button) findViewById(R.id.engBut);
engBut.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(Language.this);
builder.setCancelable(true);
builder.setTitle("DISCLAIMER");
builder.setMessage(R.string.result_disclaimer);
builder.setNegativeButton("Get me out of here.", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
}
});
builder.setPositiveButton("I agree.", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(getApplicationContext(),MainActivity.class);
intent.setAction("com.techideas4you.pharamacy.MyAction");
intent.addCategory("android.intent.category.DEFAULT");
startActivity(intent);
}
});
builder.show();
}
});
fraBut = (Button) findViewById(R.id.fraBut);
Log.i("Locale", String.valueOf(Locale.getDefault()));
}
}
This was my first page code.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example.ex"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" />
<permission android:name="testDisclaimer" android:label="DISCLAIMER"
android:description="#string/result_disclaimer"/>
   
<uses-permission android:name="testDisclaimer"/>
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="#string/app_name">
</activity>
<activity
android:name=".ActivityQuestion"
android:icon="#drawable/home"
android:label="Home"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".ActivityResult"
android:icon="#drawable/home"
android:label="Home"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity android:name=".Language">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter >
<action android:name="com.techideas4you.pharamacy.MyAction"
/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
and this is my manifest if anybody could help me out here I really appreciate it.
You have to add android:protectionLevel="dangerous" to the declaration of your permission else it will be granted automatically and users will not be presented with a dialog although you call requestPermission().
<permission android:name="your.package.name.permission.testDisclaimer" android:label="DISCLAIMER"
android:description="#string/result_disclaimer"
android:protectionLevel="dangerous"/>
<uses-permission android:name="your.package.name.permission.testDisclaimer"/>
In order to have the runtime show the disclaimer, you have to call
requestPermissions(new String[]{"your.package.name.permission.testDisclaimer"}, 42);
The result (whether user agreed) will be transmitted to you in onRequestPermissionsResult()
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults)
{
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 42 && grantResults != null){
Toast.makeText(this, "Permission " + permissions[0] + (grantResults[0] == PERMISSION_GRANTED ? "" : " NOT ") + " granted! ", Toast.LENGTH_LONG).show();
}
}
Please note that by using the permission system, you also have to cope with the fact that users will NOT be shown the permission-request-disguised-as-disclaimer if they
[...] turned down the permission request in the past and chose the
Don't ask again option in the permission request system dialog [...]
(quoted from documentation).
So maybe simply writing a flag to SharedPreferences will do the job just as well.

onActivityResult does not get result ? +schema

From some Fragment I call an Activity like this:
private void setEmailChangeListener() {
emailChangeButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), EmailChangeActivity.class);
startActivityForResult(intent, 1);
}
});
}
In that Activity I make some changes to e-mail in database and then update info in local database (updated e-mail and update time and date). Then I call setResult:
if (!error) {
JSONObject user = jObj.getJSONObject("user");
String updatedAt = user.getString("updated_at");
String userUniqueId = db.getUserUniqueId();
db.updateUpdatedAt(updatedAt, userUniqueId);
Intent returnIntent = new Intent();
setResult(Activity.RESULT_OK, returnIntent);
finish();
} else {
String errorMsg = jObj.getString("error_msg");
showSnackbarInfo(errorMsg, R.color.snackbar_error);
}
In Activity with opened Fragment I want to update info in Fragment by detach and attach in order to refrsh it. I do it in onActivityResult like this:
// Result From Other Activities
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == 1) {
Log.i("result", "reqCode = 1, zmieniam adres email w nav draw i odswierzam fragment");
navHeaderEmail.setText(db.getEmailAdress());
Fragment fragment = getSupportFragmentManager().findFragmentByTag(
TAG_FRAGMENT_ACCOUNT_SETTINGS);
FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.detach(fragment);
fragmentTransaction.attach(fragment);
fragmentTransaction.commit();
showSnackbarInfo(getString(R.string.inf_email_change_success),
R.color.snackbar_success);
}
}
After calling setResult nothing happens just like I didn't set the result properly or something else. Could you help me with this?
Here is schema how it should work:
Edit:
Here is my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.nazwamarki.myapplication">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:name=".app.AppController"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/application_name"
android:theme="#style/AppTheme">
<!-- Home Activity -->
<activity
android:name=".HomeActivity"
android:label="#string/application_name"
android:theme="#style/AppTheme.Normal">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Login Activity -->
<activity
android:name=".LoginActivity"
android:label="#string/login_activity_name"
android:parentActivityName=".HomeActivity"
android:theme="#style/AppTheme.Logreg">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.nazwamarki.myapplication.HomeActivity" />
</activity>
<!-- Sign Up Activity -->
<activity
android:name=".SignUpActivity"
android:label="#string/register_activity_name"
android:parentActivityName=".HomeActivity"
android:theme="#style/AppTheme.Logreg">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.nazwamarki.myapplication.HomeActivity" />
</activity>
<!-- Email Change Activity -->
<activity
android:name=".EmailChangeActivity"
android:label="#string/change_email_activity_name"
android:theme="#style/AppTheme.Normal">
</activity>
<!-- Password Change Activity -->
<activity
android:name=".PasswordChangeActivity"
android:label="#string/change_password_activity_name"
android:theme="#style/AppTheme.Normal">
</activity>
<!-- Recipe Activity -->
<activity
android:name=".RecipeActivity"
android:label="#string/recipe_activity_name"
android:parentActivityName=".HomeActivity"
android:theme="#style/AppTheme.Normal">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.nazwamarki.myapplication.HomeActivity" />
</activity>
</application>
</manifest>
can you try
getActivity().startActivityForResult(intent, 1);
or override onActivityResult in the fragment it self
I had the problem in reverse I was trying to use onActivityResult inside my fragment but sometimes it went to the parent activity so I ended up using the first line and handling it in the parent actvity

Android Start new activity first time

Android app issue:
I have MainActivity that when you press a button it opens the camera (an OCR) via Intent and startActivity. The problem is when I press the button in my mobile the first time after the installation, it gets blocked.
Then, after the first time, it works perfect...
By the way, when I try to execute the app in the android emulator it gives me only one error: "error opening trace file: No such file or directory" I don't know if this error is related with my problem in the mobile.
Here is the intent of MainActivity
Button2.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
try {
Intent i = new Intent(getApplicationContext(), CaptureActivity.class);
startActivityForResult(i, REQUEST_CODE);
} catch (Exception e) {
}
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK && requestCode == REQUEST_CODE) {
if (data.hasExtra("ocrResult")) {
EditText.setText(data.getExtras().getString("ocrResult"));
} else if (resultCode == RESULT_CANCELED) {
}
}
}
And here you have the code of the OCR that sends the result to MainActivity
public void onClick(View v) {
finish();
}
public void finish() {
Intent data = new Intent();
data.putExtra("ocrResult", ocrResultView.getText());
setResult(RESULT_OK, data);
super.finish();
}
Finally, the manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.sfsu.cs.orange.ocr"
android:installLocation="auto"
android:versionName="0.5.13"
android:versionCode="32"
>
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="13"/>
<supports-screens android:xlargeScreens="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.flash" android:required="false" />
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.screen.landscape"/>
<application android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<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>
<activity android:name=".CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden"
>
</activity>
<activity android:name="edu.sfsu.cs.orange.ocr.PreferencesActivity"> </activity>
</application>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
Thank you very much!!

Android Security Exception while accessing contacts

This is totally weird and I've searched through the forums.
In my main class I have a button onClick will launch the contacts application as shown below. When I click the button, he contacts list is shown but as soon as I tap on a contact a security exception is thrown.
public void selectContacts(View v) {
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case PICK_CONTACT:
if (resultCode == Activity.RESULT_OK) {
Uri contactData = data.getData();
Cursor c = managedQuery(contactData, null, null, null, null);
while (c.moveToNext()) {
String id = c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
String phoneNumber = getPhoneNumber(id);
listOfContacts.add(phoneNumber);
}
} else {
System.out.println("User didn't pick a contact");
finish();
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
I've checked the manifest and have tried all combinations of placing the uses-permission tag, within the application, activity etc. But nothing works. Here's my manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.company.letsmeet"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permision android:name="android.permission.SEND_SMS" />
<uses-permision android:name="android.permission.RECEIVE_SMS" />
<uses-permision android:name="android.permission.INTERNET" />
<uses-permision android:name="android.permission.READ_CONTACTS" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".LetsmeetActivity"
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>
The security exception :
05-04 11:26:39.950: E/AndroidRuntime(3861): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://com.android.contacts/contacts/7 }} to activity {in.company.letsmeet/in.company.letsmeet.LetsmeetActivity}: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.SemcContactsProvider2 uri content://com.android.contacts/contacts/7 from pid=3861, uid=10093 requires android.permission.READ_CONTACTS
Any help will be greatly appreciated. I'm trying this on Android 2.1 Sony experia S10 mini.
So guess what, I added the READ_CONTACTS permission in the Manifest GUI and it works. God I wasted an entire day on this. Hope others don't have to.
Try out below code.That may be helpful to you -
public class PickDemo extends Activity {
private static final int PICK_REQUEST=1337;
private static Uri CONTENT_URI=null;
static {
int sdk=new Integer(Build.VERSION.SDK).intValue();
if (sdk>=5) {
try {
Class<?> clazz=Class.forName("android.provider.ContactsContract$Contacts");
CONTENT_URI=(Uri)clazz.getField("CONTENT_URI").get(clazz);
}
catch (Throwable t) {
Log.e("PickDemo", "Exception when determining CONTENT_URI", t);
}
}
else {
CONTENT_URI=Contacts.People.CONTENT_URI;
}
}
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (CONTENT_URI==null) {
Toast
.makeText(this, "We are experiencing technical difficulties...",
Toast.LENGTH_LONG)
.show();
finish();
return;
}
setContentView(R.layout.main);
Button btn=(Button)findViewById(R.id.pick);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent i=new Intent(Intent.ACTION_PICK, CONTENT_URI);
startActivityForResult(i, PICK_REQUEST);
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode==PICK_REQUEST) {
if (resultCode==RESULT_OK) {
startActivity(new Intent(Intent.ACTION_VIEW,
data.getData()));
}
}
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest android:versionCode="1"
android:versionName="1.0"
package="com.commonsware.android.contacts.pick"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="3"
android:targetSdkVersion="6" />
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false" />
<application android:icon="#drawable/cw"
android:label="#string/app_name">
<activity android:label="#string/app_name"
android:name=".PickDemo">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And, just refer Commonsware's example. Hope this helps you.

Run a task in background always in android

I have a problem that I made a service which executes a task in background after every 5 seconds, for this I made a receiver in manifest and autostarter class but it is not excuted in my app. Means the service is not running in the app. I don't know why? Please suggest me for the right answer.
Android Manifest:
<application android:icon="#drawable/icon" android:label="#string/app_name">
<receiver android:name="com.halosys.TvAnyTime.ServiceAutoStarter">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity android:name=".MainScreen"
android:label="#string/app_name" android:screenOrientation="portrait" android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".IntroVideo" android:label="#string/app_name" android:theme="#style/CustomTheme" android:screenOrientation="landscape"/>
<activity android:name=".WelcomeScreen1" android:theme="#android:style/Theme.NoTitleBar" android:screenOrientation="portrait"/>
<activity android:name=".IntroFaceBookScreen" android:theme="#android:style/Theme.NoTitleBar" android:screenOrientation="portrait"/>
</application>
<uses-permission xmlns:android="http://schemas.android.com/apk/res/android"
android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
<uses-permission android:name="android.permission.READ_INPUT_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-sdk android:minSdkVersion="3" />
</manifest>
ServiceAutoStarter:
public class ServiceAutoStarter extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Intent myIntent = new Intent(context, ServiceTemplate.class);
myIntent.putExtra("extraData", "somedata");
context.startService(myIntent);
}
}
ServiceTemplate.java:
public class ServiceTemplate extends Service {
Runnable refresher;
public static int HashesInPattern=32; // 32 64byte hashes in the pattern
public static int BytesInHash =64;
static byte[] hashPattern;
ArrayList<byte[]> finalHashafterXor = new ArrayList<byte[]>();
byte[] finaldatafile = new byte[2097152];
byte[] finalhash;
InputStream is;
byte[] bytesafterXor,bytes;
String strLine;
#Override
public IBinder onBind(Intent intent) {
return null;
}
#Override
public void onCreate() {
//code to execute when the service is first created
}
#Override
public void onDestroy() {
//code to execute when the service is shutting down
}
#Override
public void onStart(Intent intent, int startid) {
//code to execute when the service is starting up
final Handler handler = new Handler();
refresher = new Runnable() {
public void run() {
// some action
try{
Encrypt();
Toast.makeText(getApplicationContext(), "Hello World", Toast.LENGTH_SHORT).show();
}
catch(Exception e)
{
e.printStackTrace();
}
handler.postDelayed(refresher, 2000);
}
};
}
Thanks in advance.
I haven't gone through whole of your code but i saw manifest file
Like activities (and other components), you must declare all services in your application's manifest file.
Please do change and try.

Categories

Resources