<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>what is NotificationActivity ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63062/what-is-notificationactivity</link><description>public class NotificationActivity extends Activity { @Override protected void onCreate (Bundle savedInstanceState) { super .onCreate(savedInstanceState) ; // If this activity is the root activity of the task, the app is not running if (isTaskRoot()) </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 28 Jun 2020 23:30:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63062/what-is-notificationactivity" /><item><title>RE: what is NotificationActivity ?</title><link>https://devzone.nordicsemi.com/thread/257255?ContentTypeID=1</link><pubDate>Sun, 28 Jun 2020 23:30:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:206bf9e1-977d-4a08-924b-ceb1f0c648a6</guid><dc:creator>Serobegi</dc:creator><description>&lt;p&gt;Thanks for the answer.&lt;/p&gt;
&lt;p&gt;FeaturesActivity was created by referring to Toolbox github.&lt;/p&gt;
&lt;p&gt;My goal is to simply OTA a specified file in a set directory.&lt;/p&gt;
&lt;p&gt;The code has been modified in the last two days and is written as follows. But still, I am not sure why NotificationActivity is used. What should the class call by Intent of NotificationActivity class contain?&lt;/p&gt;
&lt;p&gt;The program I am writing is performed by starting MainActivity -&amp;gt; OTA Activity is called -&amp;gt; Work progress -&amp;gt; Returning MainActivity.&lt;/p&gt;
&lt;p&gt;My English was wrong, so I got help from a Google translator. I will wait for your answer. I want to say thank you again.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;// Try to create sample files
if (FileHelper.newSamplesAvailable(this)) {
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
        Log.d(&amp;quot;FileHelper &amp;quot;, &amp;quot;createSamples&amp;quot;);
        FileHelper.createSamples(this);
    } else {
        ActivityCompat.requestPermissions(OTA.this, new String[]{Manifest.permission.READ_CONTACTS}, MY_PERMISSIONS_WRITE_EXTERNAL_STORAGE);
    }
}

...

otaStartButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final DfuServiceInitiator starter = new DfuServiceInitiator(SwitchDeviceMac)
                        .setDeviceName(SwitchDeviceName)
                        .setKeepBond(false)
                        .setForceDfu(false)
                        .setPacketsReceiptNotificationsEnabled(Build.VERSION.SDK_INT &amp;lt; Build.VERSION_CODES.M)
                        .setPacketsReceiptNotificationsValue(DfuServiceInitiator.DEFAULT_PRN_VALUE)
                        .setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(true)
                        .setPrepareDataObjectDelay(300L);

                final File root = new File(Environment.getExternalStorageDirectory(), &amp;quot;Nordic&amp;quot;);
                final File file = new File(root, &amp;quot;FILE&amp;quot;);

                starter.setZip(file.getPath());
                final DfuServiceController controller = starter.start(OTA.this, com.example.coolproject.DfuService.class);
            }
        });

...

private final DfuProgressListener dfuProgressListener = new DfuProgressListenerAdapter() {
        @Override
        public void onDeviceConnecting(final String deviceAddress) {
            otaStateTextView.setText(R.string.dfu_status_connecting);
            Log.d(&amp;quot;onDeviceConnecting&amp;quot;, deviceAddress);
        }

        @Override
        public void onDfuProcessStarting(final String deviceAddress) {
            otaStateTextView.setText(R.string.dfu_status_starting);
            Log.d(&amp;quot;onDfuProcessStarting&amp;quot;, deviceAddress);
        }

        @Override
        public void onEnablingDfuMode(final String deviceAddress) {
            otaStateTextView.setText(R.string.dfu_status_starting);
            Log.d(&amp;quot;onEnablingDfuMode &amp;quot;, deviceAddress);
        }

        @Override
        public void onDfuCompleted(@NonNull String deviceAddress) {
            super.onDfuCompleted(deviceAddress);
            otaStateTextView.setText(R.string.dfu_status_completed);
            final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            manager.cancel(DfuService.NOTIFICATION_ID);
            Log.d(&amp;quot;onDfuCompleted&amp;quot;, deviceAddress);
        }

        @Override
        public void onError(final String deviceAddress, final int error, final int errorType, final String message) {
            final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            manager.cancel(DfuService.NOTIFICATION_ID);
            Log.d(&amp;quot;onError&amp;quot;, error + &amp;quot; / &amp;quot; + errorType + &amp;quot; / &amp;quot; + message);
        }

        @Override
        public void onDfuAborted(final String deviceAddress) {
            final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            manager.cancel(DfuService.NOTIFICATION_ID);
            Log.d(&amp;quot;onDfuAborted&amp;quot;, deviceAddress);
        }
    };
    
    ---------
    
    public class NotificationActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // If this activity is the root activity of the task, the app is not running
        if (isTaskRoot()) {
            // Start the app before finishing

            final Intent intent = new Intent(this, OTA.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtras(getIntent().getExtras()); // copy all extras
            startActivity(intent);
        }

        // Now finish, which will drop you to the activity at which you were at the top of the task stack
        finish();
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: what is NotificationActivity ?</title><link>https://devzone.nordicsemi.com/thread/257183?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2020 15:07:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f80bdded-7ad7-44fd-b432-88f198fe150e</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]The code above is the sample code provided by GitHub.&lt;br /&gt;But I don&amp;#39;t use what is called FeaturesActivity. So what class should I put there?&lt;br /&gt;Below is my code. How would you like to modify it?[/quote]
&lt;p&gt;Have you seen &lt;a href="https://github.com/NordicSemiconductor/Android-DFU-Library/tree/release/documentation"&gt;the notificationActivity&amp;#39;s description in the Android DFU Library documentation&lt;/a&gt;?&lt;br /&gt;Furthermore, could you elaborate on what you would like the application to do - why are you changing this part - what is the desired behavior from the code you have written in place of the original code?&lt;br /&gt;&lt;br /&gt;Looking forward to resolving this issue together,&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>