Simple MD5Sum Generator Used for Warm and Synergy Updater

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.IO;

namespace WarmMD5Sum
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Get current application directory path
            string executableName = Application.ExecutablePath;
            FileInfo executableFileInfo = new FileInfo(executableName);
            string executableDirectoryName = executableFileInfo.DirectoryName;

            // Process the list of zip files found in directory where this program is running
            string[] fileEntries = Directory.GetFiles(executableDirectoryName, "*.zip");

            string filesProcessed = "Files Processed:" + Environment.NewLine + Environment.NewLine;

            foreach (string fileName in fileEntries)
            {
                // Generate MD5Sum from file
                byte[] b = System.IO.File.ReadAllBytes(fileName);
                string sum = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(b)).Replace("-", "").ToLower();

                // Create MD5Sum file  
                string MD5SumOutputFile = fileName + ".MD5Sum";
                TextWriter tw = new StreamWriter(MD5SumOutputFile);
                tw.WriteLine(sum);
                tw.Close(); 
               
                // Record what files were processed
                filesProcessed += fileName + Environment.NewLine + Environment.NewLine;
            }

            MessageBox.Show(filesProcessed);

        }
    }
}

Advertisements

Creating an Android Activity with no UI

How do you create an Activity based applications with no UI?

The answer is that you need to set the activity theme in the manifest, for RosieUtility I use:

android:theme="@android:style/Theme.Translucent.NoTitleBar"

Like this in AndroidManifest.xml:

<activity android:name=".MainActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

If you just want to kick off something quick, you’ll also want to call “finish();” after firing the intent in onCreate of Activity

The latest set of activity themes are defined in /res/values/themes.xml in the Android source here.

Note I’m not using the theme ‘NoDisplay’ as I do actually show notifications on the screen as the Activity is going about its business.

Source

Launch Activity/Service On Android Boot

OnBootReceiver.java

package com.logicvoid.voguetools;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

public  class OnBootReceiver extends  BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
         if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
              Log.d("VogueTools", "Got the Boot Event>>>");
              // do your stuff for example, start a background service directly
              // here
              Toast.makeText(context, "Testing From VogueTools", 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.logicvoid.voguetools"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" 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>

		<!--   Handling for On Boot Receiver -->
		 <receiver android:name=".OnBootReceiver"  android:enabled="true"  android:exported="false"  android:label="OnBootReceiver">
		    <intent-filter>
		        <action android:name="android.intent.action.BOOT_COMPLETED" />
		    </intent-filter>
		</receiver>
		 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
		<!-- End Handling for On Boot Receiver -->

    </application>
    <uses-sdk android:minSdkVersion="4" />

</manifest>

For reference. the Context passed in the onReceive is that of the Application, not a specific Activity.

If you’re doing anything that is context sensitive like dealing with preferences in your application, perhaps using appContext.getSharedPreferences. Use getApplicationContext() within your application to ensure the preferences will be read from both the BroadcastReceiver onReceive and the application itself. As the onReceive Context is that of the application, they will be equal.