@Override protected void onDestroy() { super.onDestroy(); if (mSentReceiver != null) { unregisterReceiver(mSentReceiver); } if (mReceivedReceiver != null) { unregisterReceiver(mReceivedReceiver); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mms_demo); final CheckBox enableCheckBox = (CheckBox) findViewById(R.id.mms_enable_receiver); final PackageManager pm = this.getPackageManager(); final ComponentName componentName = new ComponentName("com.example.android.apis", "com.example.android.apis.os.MmsWapPushReceiver"); mRecipientsInput = (EditText) findViewById(R.id.mms_recipients_input); mSubjectInput = (EditText) findViewById(R.id.mms_subject_input); mTextInput = (EditText) findViewById(R.id.mms_text_input); mSendStatusView = (TextView) findViewById(R.id.mms_send_status); mSendButton = (Button) findViewById(R.id.mms_send_button); mSendButton.setOnClickListener(new View.OnClickListener() { @Override registerReceiver(mSentReceiver, mSentFilter); registerReceiver(mReceivedReceiver, mReceivedFilter); final Intent intent = getIntent(); final String notificationIndUrl = intent.getStringExtra(EXTRA_NOTIFICATION_URL); if (!TextUtils.isEmpty(notificationIndUrl)) { downloadMessage(notificationIndUrl);
private void downloadMessage(final String locationUrl) { Log.d(TAG, "Downloading " + locationUrl); mSendStatusView.setText(getResources().getString(R.string.mms_status_downloading)); mSendButton.setEnabled(false); mRecipientsInput.setText(""); mSubjectInput.setText(""); mTextInput.setText(""); final String fileName = "download." + String.valueOf(Math.abs(mRandom.nextLong())) + ".dat"; mDownloadFile = new File(getCacheDir(), fileName); // Making RPC call in non-UI thread // AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() { // @Override // public void run() { // Uri contentUri = (new Uri.Builder()) // .authority("com.example.android.apis.os.MmsFileProvider") // .path(fileName) // .scheme(ContentResolver.SCHEME_CONTENT) // .build(); // final PendingIntent pendingIntent = PendingIntent.getBroadcast( // MmsMessagingDemo.this, 0, new Intent(ACTION_MMS_RECEIVED), 0); // SmsManager.getDefault().downloadMultimediaMessage(getApplicationContext(), // locationUrl, contentUri, null/*configOverrides*/, pendingIntent); // } // }); }
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); final String notificationIndUrl = intent.getStringExtra(EXTRA_NOTIFICATION_URL); if (!TextUtils.isEmpty(notificationIndUrl)) { downloadMessage(notificationIndUrl); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mms_demo); final CheckBox enableCheckBox = (CheckBox) findViewById(R.id.mms_enable_receiver); final PackageManager pm = this.getPackageManager(); final ComponentName componentName = new ComponentName("com.example.android.apis", "com.example.android.apis.os.MmsWapPushReceiver"); mRecipientsInput = (EditText) findViewById(R.id.mms_recipients_input); mSubjectInput = (EditText) findViewById(R.id.mms_subject_input); mTextInput = (EditText) findViewById(R.id.mms_text_input); mSendStatusView = (TextView) findViewById(R.id.mms_send_status); mSendButton = (Button) findViewById(R.id.mms_send_button); mSendButton.setOnClickListener(new View.OnClickListener() { @Override registerReceiver(mSentReceiver, mSentFilter); registerReceiver(mReceivedReceiver, mReceivedFilter); final Intent intent = getIntent(); final String notificationIndUrl = intent.getStringExtra(EXTRA_NOTIFICATION_URL); if (!TextUtils.isEmpty(notificationIndUrl)) { downloadMessage(notificationIndUrl);
private void downloadMessage(final String locationUrl) { Log.d(TAG, "Downloading " + locationUrl); mSendStatusView.setText(getResources().getString(R.string.mms_status_downloading)); mSendButton.setEnabled(false); mRecipientsInput.setText(""); mSubjectInput.setText(""); mTextInput.setText(""); final String fileName = "download." + String.valueOf(Math.abs(mRandom.nextLong())) + ".dat"; mDownloadFile = new File(getCacheDir(), fileName); // Making RPC call in non-UI thread // AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() { // @Override // public void run() { // Uri contentUri = (new Uri.Builder()) // .authority("com.example.android.apis.os.MmsFileProvider") // .path(fileName) // .scheme(ContentResolver.SCHEME_CONTENT) // .build(); // final PendingIntent pendingIntent = PendingIntent.getBroadcast( // MmsMessagingDemo.this, 0, new Intent(ACTION_MMS_RECEIVED), 0); // SmsManager.getDefault().downloadMultimediaMessage(getApplicationContext(), // locationUrl, contentUri, null/*configOverrides*/, pendingIntent); // } // }); }
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); final String notificationIndUrl = intent.getStringExtra(EXTRA_NOTIFICATION_URL); if (!TextUtils.isEmpty(notificationIndUrl)) { downloadMessage(notificationIndUrl); } }
private void sendMessage(final String recipients, final String subject, final String text) { Log.d(TAG, "Sending"); mSendStatusView.setText(getResources().getString(R.string.mms_status_sending)); mSendButton.setEnabled(false); final String fileName = "send." + String.valueOf(Math.abs(mRandom.nextLong())) + ".dat"; mSendFile = new File(getCacheDir(), fileName);
@Override protected void onDestroy() { super.onDestroy(); if (mSentReceiver != null) { unregisterReceiver(mSentReceiver); } if (mReceivedReceiver != null) { unregisterReceiver(mReceivedReceiver); } }
private void sendMessage(final String recipients, final String subject, final String text) { Log.d(TAG, "Sending"); mSendStatusView.setText(getResources().getString(R.string.mms_status_sending)); mSendButton.setEnabled(false); final String fileName = "send." + String.valueOf(Math.abs(mRandom.nextLong())) + ".dat"; mSendFile = new File(getCacheDir(), fileName);