Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8137017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:57:07+00:00 2026-06-06T10:57:07+00:00

I am uploading a video using FTP. I am showing a notification also for

  • 0

I am uploading a video using FTP. I am showing a notification also for that. If I click the notification it will take me to the application screen. So the same screen will run two times. So I need to click back button two times. I want to avoid this. Please help me…

public class loadVideo extends AsyncTask<Void, Void, Void> {
        String status = null;
        FTPClient ftp = new FTPClient();
        InputStream in = null;
        int progress = 2;
        String dbftpserver, dbftpusername, dbftpPassword, dbftpPort,
                dbftpDirPath = null;
        String hostName, username, password = null;
        NotificationManager notificationManager = (NotificationManager) getApplicationContext()
                .getSystemService(Context.NOTIFICATION_SERVICE);

        int id = 10;

        @Override
        protected Void doInBackground(Void... arg0) {
            UUID uniqueKey = UUID.randomUUID();
            fname = uniqueKey.toString();
            Log.e("UNIQUE NAME", fname);
            String strquery1 = "SELECT FTP_Server,FTP_Username,FTP_Password,FTP_PORT,FTP_Directory_Path FROM hwd_settings WHERE ID = 1 ";
            Cursor mCursor = (MainscreenActivity.JEEMAHWDroidDB).rawQuery(
                    strquery1, null);
            if (mCursor.getCount() != 0) {
                mCursor.moveToLast();
                for (int i = mCursor.getCount() - 1; i >= 0; i--) {
                    dbftpserver = mCursor.getString(0);
                    dbftpusername = mCursor.getString(1);
                    dbftpPassword = mCursor.getString(2);
                    dbftpPort = mCursor.getString(3);
                    dbftpDirPath = mCursor.getString(4);
                }
            }
            hostName = dbftpserver;
            username = dbftpusername;
            password = dbftpPassword;
            try {
                ftp.connect(hostName);
                ftp.login(username, password);
                ftp.setFileType(FTP.BINARY_FILE_TYPE);
                ftp.enterLocalPassiveMode();
                ftp.changeWorkingDirectory(dbftpDirPath + "uploads");
                int reply = ftp.getReplyCode();
                System.out.println("Received Reply from FTP Connection:"
                        + reply);
                if (FTPReply.isPositiveCompletion(reply)) {
                    System.out.println("Connected Success");                    
                    doftpVideo();
                } else {
                    Log.e("FTP", "CONNECTION ERROR");
                    finish();
                    Toast.makeText(getApplicationContext(),
                            "Unable to connect FTP", Toast.LENGTH_LONG).show();
                }
                return null;
            } catch (Exception i) {
                i.printStackTrace();
                String temp = i.toString();
                if (temp.equalsIgnoreCase("java.net.UnknownHostException: "
                        + hostName)) {
                    showAlert();
                }

            }
            return null;
        }

        private void showAlert() {
            AlertDialog.Builder alert = new AlertDialog.Builder(
                    NewVideoActivity.this);
            alert.setMessage("Unable to connect FTP");
            alert.setPositiveButton(getResources().getString(R.string.ok),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                int whichButton) {
                            dialog.cancel();
                        }
                    }).show();
        }

        public void doftpVideo() {
            Intent intent1 = new Intent(NewVideoActivity.this,
                    MainscreenActivity.class);
            final PendingIntent pendingIntent = PendingIntent.getActivity(
                    getApplicationContext(), 0, intent1, 0);
            Notification notification = new Notification();
            final String location = selectedPath;
            final SharedPreferences prefs = PreferenceManager
                    .getDefaultSharedPreferences(getApplicationContext());
            SharedPreferences.Editor prefsEditor = prefs.edit();
            try {
                int icon = R.drawable.video_upload; // icon from resources
                CharSequence tickerText = "Starting Video Upload"; // ticker-text
                long when = System.currentTimeMillis(); // notification time
                Context context = getApplicationContext(); // application
                                                            // Context
                CharSequence contentTitle = "JEEMAHWDroid"; // expanded message
                                                            // title
                CharSequence contentText = "Uploading " + strTitle; // expanded
                                                                    // message
                                                                    // text
                notification = new Notification(icon, tickerText, when);
                notification.flags = notification.flags
                        | Notification.FLAG_ONLY_ALERT_ONCE
                        | Notification.FLAG_NO_CLEAR;
                notification.setLatestEventInfo(context, contentTitle,
                        contentText, pendingIntent);
                notificationManager.notify(id, notification);
                File f1 = new File(location);
                in = new FileInputStream(f1);
                ftp.storeFile(fname + "." + extension, in);
                System.out.println("SUCCESS");
                System.out.println("Video Title:" + strTitle
                        + " is uploaded successfully");
                System.out.println("Video Name:" + fname
                        + " is uploaded successfully");
                status = "completed";
                prefsEditor.putString("status", status);
                prefsEditor.commit();
                String tempStatus = prefs.getString("status", null);
                System.out.println("tempSTATUS-->>>" + tempStatus);
                strUserName = prefs.getString(
                        getResources().getString(R.string.username), null);
                strToken = prefs.getString(
                        getResources().getString(R.string.token), null);
                url = prefs.getString("VALUE", null);
                doftpImage();
                doCreateRecord();
            } catch (Exception i) {
                i.printStackTrace();
            }
            return;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:57:09+00:00Added an answer on June 6, 2026 at 10:57 am

    Try setting android:launchMode="singleInstance" for MainscreenActivity in your AndroidManifest.xml

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a web application for video uploading,In that i want to show the
I am uploading video on twitvid using its official php library. http://www.martin-gardner.co.uk/twitvid/twitvid.class.example.php#embedvideo But when
I am facing the following issue while uploading the video from my android application.
Hi i want to create an uploading video program using youtube api I think
I am uploading a video file using an Async Task. To track the progress
I'm trying to change video dimensions using ffmpeg. For example, user is uploading video
I am trying to upload video from the iPhone application using FBConnect. Actually I
How to a create thumb image while uploading a video, am using the following
In C#, I'm uploading a video file to Facebook from a server, using the
In my iPhone application, I've noticed that when using the UIImagePickerController it typically causes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.