Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
themeConfluence
titleLoaderSample
linenumberstrue
collapsetruemanual LoaderSample
public class LoaderSample implements LoaderCallback
{
	Context _c; 
	public LoaderSample(Context c)
	{
		this._c = c;
	} 
	
	@Override
	public void onLoaded() 
	{
		//loading the JCE has finished 
		//get provider
		Provider p = Security.getProvider("CERTGATE"); 
		//do something with the provider
		...
	} 
	
	public void startLoading() throws ProviderLoadingFailedException, ProviderSignatureInvalidException, ProviderNotFoundException
	{
		if (ProviderLoader.isProviderInstalled(this._c))
		{
			if (!ProviderLoader.isProviderAvailable())
			{
				ProviderLoader.load(this._c, this);
			}
			else
			{
				//already loaded!
			}
		}
		else
		{
			//not installed!
		}
	}
}

...

For easier integration we implemented the JCEInitTask which extends from Android's AsyncTask and loads the cgJCE with more detailed success / failure information.
It is recommended to implement the OnTaskFinishCallback since it gives information about how the loading resulted.
Furthermore loading the cgJCE by this task gives the opportunity to fade-in a progress- or a custom dialog which dissapears after the loading has finished. This makes sense when the user shall be blocked or notified as long as the cgJCE is loading. The usage of this dialog is optional. When null is used as parameter a default progress dialog is shown to the user otherwise the custom dialog appears. There is also a constructor for not using any dialog.
Additionally there is the option to show message toasts when loading starts and finishes.
The following example shows how to use the JCEInitTask.

Code Block
languagejava
titleLCEInitTask LoaderSample
public class LoaderSample implements OnTaskFinishedCallback

...


{

...


	Context _c;

...

 
	public LoaderSample(Context c)

...


	{
		this._c = c;

...


	} 

	public void startLoading()

...


	{
		new InitJCETask(this._c, null, this, false).execute();

...


	} 

	@Override
	public void onFinished(JCELoadResult result)

...

 
	{
		switch (result)

...


		{
			case _E_ALREADY_LOADED{_}:

...


								break;

...


			case _E_NOT_INSTALLED{_}:

...


								break;

...


			case _E_SUCCESS{_}:

...


								//get

...

 providers
								ProviderLoader.getProviders();

...

 
								break;

...


			case _E_UNSPECIFIED_ERROR{_}:

...


								break;

...

 
		}
	}	
}

Anchor
_Toc456191102
_Toc456191102
Features

...