public override void onServiceConnected()
        {
            Log.d(TAG, "onServiceConnected");
            try
            {
                if (this.mMyInfo == null)
                {
                    mMyInfo = mSapaAppService.getInstalledApp(this.PackageName);
                }
                if (mMyInfo != null)
                {
                    //Actions are being set in SapaAppInfo representing this application.
                    mActionArray = new SparseArray <SapaActionInfo>();
                    mActionArray.put(0, new SapaActionInfo(COMMAND_SHUSH, R.drawable.ctrl_btn_stop_default, PackageName));
                    mMyInfo.Actions = mActionArray;

                    //Native part is being initialised.
                    Sapa sapa = new Sapa();
                    sapa.initialize(this);
                    mSapaService   = new SapaService();
                    mSapaProcessor = new SapaProcessor(this, null, new SapaProcessorStateListener(this, mMyInfo.App));
                    mSapaService.register(mSapaProcessor);
                    mSapaProcessor.activate();

                    //Information about ports is being set in SapaAppInfo representing this app.
                    //It can not be done before activating SapaProcessor.
                    mMyInfo.PortFromSapaProcessor = mSapaProcessor;

                    //Application needs to declare that it was successfully activated.
                    if (mSapaAppService != null)
                    {
                        this.mSapaAppService.addActiveApp(this.mMyInfo);
                    }
                }
            }
            catch (SapaConnectionNotSetException e)
            {
                Log.e(TAG, "App could not be added to active as connection has not been made.");
            }
            catch (System.ArgumentException e)
            {
                Log.e(TAG, "Initialisation of Sapa is not possible due to invalid context of application");
            }
            catch (SsdkUnsupportedException e)
            {
                Log.e(TAG, "Initialisation of Sapa is not possible as Sapa is not available on the device");
            }
            catch (InstantiationException e)
            {
                Log.e(TAG, "SapaService can not be instantiate");
            }
        }
		protected internal override void onCreate(Bundle savedInstanceState)
		{
			base.onCreate(savedInstanceState);
			ContentView = R.layout.activity_sapa_simple_piano;

			try
			{
				(new Sapa()).initialize(this);
				mService = new SapaService();
				mService.start(SapaService.START_PARAM_DEFAULT_LATENCY);
				mProcessor = new SapaProcessor(this, null, new StatusListenerAnonymousInnerClassHelper(this));
				mService.register(mProcessor);

				// copy sound font file to sdcard.
				copyAssets();

				mProcessor.sendCommand("START");
				mProcessor.activate();

			}
			catch (SsdkUnsupportedException e)
			{
				Console.WriteLine(e.ToString());
				Console.Write(e.StackTrace);
				Toast.makeText(this, "Not support Professional Audio package", Toast.LENGTH_LONG).show();
				finish();
				return;
			}
			catch (System.ArgumentException e)
			{
				Console.WriteLine(e.ToString());
				Console.Write(e.StackTrace);
				Toast.makeText(this, "Error - invalid arguments. please check the log", Toast.LENGTH_LONG).show();
				finish();
				return;
			}
			catch (InstantiationException e)
			{
				Console.WriteLine(e.ToString());
				Console.Write(e.StackTrace);
				Toast.makeText(this, "Error. please check the log", Toast.LENGTH_LONG).show();
				finish();
				return;
			}

			((Button)findViewById(R.id.play_sound_c1)).OnClickListener = new OnClickListenerAnonymousInnerClassHelper(this);
		}
Example #3
0
        protected internal override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);
            ContentView = R.layout.activity_sapa_simple_piano;

            try
            {
                (new Sapa()).initialize(this);
                mService = new SapaService();
                mService.start(SapaService.START_PARAM_DEFAULT_LATENCY);
                mProcessor = new SapaProcessor(this, null, new StatusListenerAnonymousInnerClassHelper(this));
                mService.register(mProcessor);

                // copy sound font file to sdcard.
                copyAssets();

                mProcessor.sendCommand("START");
                mProcessor.activate();
            }
            catch (SsdkUnsupportedException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
                Toast.makeText(this, "Not support Professional Audio package", Toast.LENGTH_LONG).show();
                finish();
                return;
            }
            catch (System.ArgumentException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
                Toast.makeText(this, "Error - invalid arguments. please check the log", Toast.LENGTH_LONG).show();
                finish();
                return;
            }
            catch (InstantiationException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
                Toast.makeText(this, "Error. please check the log", Toast.LENGTH_LONG).show();
                finish();
                return;
            }

            ((Button)findViewById(R.id.play_sound_c1)).OnClickListener = new OnClickListenerAnonymousInnerClassHelper(this);
        }
        private void handleActivationIntent(Intent intent)
        {
            // When application is activated from ProfessionalAudio system it
            // receives SapaAppInfo object describing it.
            // To obtain this object static method getSapaAppInfo() is to be used.
            SapaAppInfo info = SapaAppInfo.getAppInfo(intent);

            if (info != null)
            {
                string callerPackageName = intent.getStringExtra("com.samsung.android.sdk.professionalaudio.key.callerpackagename");
                if (callerPackageName == null)
                {
                    callerPackageName = "unknown";
                }
                mCallerPackageNameList[info.App.InstanceId] = callerPackageName;
                Log.d(TAG, "info.getApp.getInstanceId() " + info.App.InstanceId);
                if (!this.mAppInfoList.ContainsKey(info.App.InstanceId))
                {
                    this.mAppInfoList[info.App.InstanceId] = info;
                }
                try
                {
                    if (info.Configuration == null)
                    {
                        Log.d(TAG, "kaka, not exist configuration, volume[" + Logic.DEFAULT_VOLUME + "] will be set in " + info.App.InstanceId);
                        this.setConfiguration(info.App, Logic.DEFAULT_VOLUME);
                    }
                    else
                    {
                        Log.d(TAG, "kaka volume[" + info.Configuration.getInt("CONFIG") + "] was got from " + info.App.InstanceId);
                    }
                    // Actions are being set in SapaAppInfo representing this
                    // application.
                    mActionArray = new SparseArray <SapaActionInfo>();
                    mActionArray.put(0, new SapaActionInfo(MainActivity.VOLUME_DOWN, R.drawable.ctrl_btn_volume_down_default, this.PackageName));
                    mActionArray.put(1, new SapaActionInfo(MainActivity.VOLUME_UP, R.drawable.ctrl_btn_volume_up_default, this.PackageName));
                    info.Actions = mActionArray;

                    // Native part is being initialised.
                    SapaProcessor sapaProcessor = new SapaProcessor(this, null, new SapaProcessorStateListener(this, info.App));
                    this.mSapaService.register(sapaProcessor);
                    sapaProcessor.activate();
                    this.mProcessorList[info.App.InstanceId] = sapaProcessor;

                    Logic.sendVolume(sapaProcessor, this.getCurrectVolume(info.App));

                    // Information about ports is being set in SapaAppInfo
                    // representing this app.
                    // It can not be done before activating SapaProcessor.
                    info.PortFromSapaProcessor = sapaProcessor;

                    // Application needs to declare that it was successfully
                    // activated.
                    Log.d(TAG, "addactiveapp " + info.App.InstanceId);
                    this.mSapaAppService.addActiveApp(info);
                }
                catch (SapaConnectionNotSetException e)
                {
                    Log.e(TAG, "App could not be added to active as connection has not been made.");
                }
                catch (InstantiationException e)
                {
                    Log.e(TAG, "SapaService can not be instantiate");
                }
            }
            if (mActionsList != null && info != null && info.App != null)
            {
                this.mActionsList[info.App.InstanceId] = new ActionsPack(this, info.App);
            }
        }
Example #5
0
        private void handleActivationIntent(Intent intent)
        {
            // When application is activated from ProfessionalAudio system it
            // receives SapaAppInfo object describing it.
            // To obtain this object static method getSapaAppInfo() is to be used.
            SapaAppInfo info = SapaAppInfo.getAppInfo(intent);

            if (info != null)
            {
                string callerPackageName = intent.getStringExtra("com.samsung.android.sdk.professionalaudio.key.callerpackagename");
                if (callerPackageName == null)
                {
                    callerPackageName = "unknown";
                }
                mCallerPackageNameList[info.App.InstanceId] = callerPackageName;
                Log.d(TAG, "info.getApp.getInstanceId() " + info.App.InstanceId);
                if (!this.mAppInfoList.ContainsKey(info.App.InstanceId))
                {
                    this.mAppInfoList[info.App.InstanceId] = info;
                }
                try
                {
                    // Actions are being set in SapaAppInfo representing this
                    // application.
                    mActionArray = new SparseArray <SapaActionInfo>();
                    mActionArray.put(0, new SapaActionInfo(MainActivity.ACTION_PLAY, R.drawable.ctrl_btn_play_default, this.PackageName));
                    mActionArray.put(1, new SapaActionInfo(MainActivity.ACTION_STOP, R.drawable.ctrl_btn_stop_default, this.PackageName, true, false));
                    info.Actions = mActionArray;

                    // Native part is being initialised.
                    SapaProcessor sapaProcessor = new SapaProcessor(this, null, new SapaProcessorStateListener(this, info.App));
                    this.mSapaService.register(sapaProcessor);
                    sapaProcessor.activate();
                    this.mProcessorList[info.App.InstanceId] = sapaProcessor;

                    // Information about ports is being set in SapaAppInfo
                    // representing this app.
                    // It can not be done before activating SapaProcessor.
                    info.PortFromSapaProcessor = sapaProcessor;

                    // Application needs to declare that it was successfully
                    // activated.
                    Log.d(TAG, "addactiveapp " + info.App.InstanceId);
                    this.mSapaAppService.addActiveApp(info);
                }
                catch (SapaConnectionNotSetException e)
                {
                    Log.e(TAG, "App could not be added to active as connection has not been made.");
                }
                catch (InstantiationException e)
                {
                    Log.e(TAG, "SapaService can not be instantiate...");
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                }
            }
            if (mActionsList != null && info != null && info.App != null)
            {
                this.mActionsList[info.App.InstanceId] = new ActionsPack(this, info.App);
            }
        }
		private void handleActivationIntent(Intent intent)
		{
			// When application is activated from ProfessionalAudio system it
			// receives SapaAppInfo object describing it.
			// To obtain this object static method getSapaAppInfo() is to be used.
			SapaAppInfo info = SapaAppInfo.getAppInfo(intent);

			if (info != null)
			{
				string callerPackageName = intent.getStringExtra("com.samsung.android.sdk.professionalaudio.key.callerpackagename");
				if (callerPackageName == null)
				{
					callerPackageName = "unknown";
				}
				mCallerPackageNameList[info.App.InstanceId] = callerPackageName;
				Log.d(TAG, "info.getApp.getInstanceId() " + info.App.InstanceId);
				if (!this.mAppInfoList.ContainsKey(info.App.InstanceId))
				{
					this.mAppInfoList[info.App.InstanceId] = info;
				}
				try
				{
					// Actions are being set in SapaAppInfo representing this
					// application.
					mActionArray = new SparseArray<SapaActionInfo>();
					mActionArray.put(0, new SapaActionInfo(MainActivity.ACTION_PLAY, R.drawable.ctrl_btn_play_default, this.PackageName));
					mActionArray.put(1, new SapaActionInfo(MainActivity.ACTION_STOP, R.drawable.ctrl_btn_stop_default, this.PackageName, true, false));
					info.Actions = mActionArray;

					// Native part is being initialised.
					SapaProcessor sapaProcessor = new SapaProcessor(this, null, new SapaProcessorStateListener(this, info.App));
					this.mSapaService.register(sapaProcessor);
					sapaProcessor.activate();
					this.mProcessorList[info.App.InstanceId] = sapaProcessor;

					// Information about ports is being set in SapaAppInfo
					// representing this app.
					// It can not be done before activating SapaProcessor.
					info.PortFromSapaProcessor = sapaProcessor;

					// Application needs to declare that it was successfully
					// activated.
					Log.d(TAG, "addactiveapp " + info.App.InstanceId);
					this.mSapaAppService.addActiveApp(info);
				}
				catch (SapaConnectionNotSetException e)
				{
					Log.e(TAG, "App could not be added to active as connection has not been made.");

				}
				catch (InstantiationException e)
				{
					Log.e(TAG, "SapaService can not be instantiate...");
					Console.WriteLine(e.ToString());
					Console.Write(e.StackTrace);
				}
			}
			if (mActionsList != null && info != null && info.App != null)
			{
				this.mActionsList[info.App.InstanceId] = new ActionsPack(this, info.App);
			}
		}
		public override void onServiceConnected()
		{
			Log.d(TAG, "onServiceConnected");
			try
			{
				if (this.mMyInfo == null)
				{
					mMyInfo = mSapaAppService.getInstalledApp(this.PackageName);
				}
				if (mMyInfo != null)
				{

					//Actions are being set in SapaAppInfo representing this application.
					mActionArray = new SparseArray<SapaActionInfo>();
					mActionArray.put(0, new SapaActionInfo(COMMAND_SHUSH, R.drawable.ctrl_btn_stop_default, PackageName));
					mMyInfo.Actions = mActionArray;

					//Native part is being initialised.
					Sapa sapa = new Sapa();
					sapa.initialize(this);
					mSapaService = new SapaService();
					mSapaProcessor = new SapaProcessor(this, null, new SapaProcessorStateListener(this, mMyInfo.App));
					mSapaService.register(mSapaProcessor);
					mSapaProcessor.activate();

					//Information about ports is being set in SapaAppInfo representing this app.
					//It can not be done before activating SapaProcessor.
					mMyInfo.PortFromSapaProcessor = mSapaProcessor;

					//Application needs to declare that it was successfully activated.
					if (mSapaAppService != null)
					{
						this.mSapaAppService.addActiveApp(this.mMyInfo);
					}
				}
			}
			catch (SapaConnectionNotSetException e)
			{
				Log.e(TAG, "App could not be added to active as connection has not been made.");
			}
			catch (System.ArgumentException e)
			{
				Log.e(TAG, "Initialisation of Sapa is not possible due to invalid context of application");
			}
			catch (SsdkUnsupportedException e)
			{
				Log.e(TAG, "Initialisation of Sapa is not possible as Sapa is not available on the device");
			}
			catch (InstantiationException e)
			{
				Log.e(TAG, "SapaService can not be instantiate");
			}
		}