This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package YOUR_PACKAGE; | |
import android.content.Context; | |
import android.os.Build; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.security.KeyStore; | |
import java.security.KeyStoreException; | |
import java.security.cert.Certificate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package X.Y.Z; | |
import android.text.TextUtils; | |
import android.util.Base64; | |
/** | |
* Created by ylemin on 07/09/15. | |
* | |
* This class is similar in functionalities as the commons.lang.StringUtils, but using as much | |
* of the Android built-in tools and helpers as possible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package X.Y.Z; | |
import android.content.SharedPreferences; | |
/** | |
* Created by ylemin on 21/11/15. | |
* | |
* This class is a bunch of recurring methods used when dealing with SharedPreferences. | |
* It is intended to be a base class which receives the SharedPreferences instance from the child class. | |
* There should only be one instance of SharedPreferences per app. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onDeleted(Context context, int[] appWidgetIds) { | |
super.onDeleted(context, appWidgetIds); | |
WidgetEntryDao dao = new WidgetEntryDao(new DbHelper(context)); | |
final int N = appWidgetIds.length; | |
for (int i = 0; i < N; i++) { | |
dao.deleteByWidgetId(appWidgetIds[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// creating the intent with all the information we want to pre-fill | |
Intent intent = new Intent(Intent.ACTION_SEND); | |
// array of destination email addresses | |
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]", "[email protected]" }); | |
intent.putExtra(Intent.EXTRA_SUBJECT, "my subject"); | |
intent.putExtra(Intent.EXTRA_TEXT, "some message body"); | |
// This type narrows down the amount of apps that will be displayed in the app choice dialog | |
intent.setType("message/rfc822"); // it should be mostly email apps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { | |
WidgetEntryDao dao = new WidgetEntryDao(new DbHelper(context)); | |
final int N = appWidgetIds.length; | |
// Perform this loop procedure for each App Widget that belongs to this provider | |
for (int i = 0; i < N; i++) { | |
int appWidgetId = appWidgetIds[i]; |