Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can make the sample run fine but unable to deploy the lib in any project #149

Open
Taprik opened this issue Nov 14, 2018 · 0 comments
Open

Comments

@Taprik
Copy link

Taprik commented Nov 14, 2018

I'm able to run the sample in the library and send mms with image. Perfect.
But I can't add this functionnality in a project.
I've try it several times on existing project, on new projet, ...
Here is what I've done :

  1. add the library to gradle and sync
    implementation 'com.klinkerapps:android-smsmms:5.1.0'

  2. add the classes of sample (MMSReceiver, permissionActivity, Settings, ...)

  3. add this code on my mainActivity (mainly based on the code of the sample in library
    `@Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

     if (PreferenceManager.getDefaultSharedPreferences(this)
             .getBoolean("request_permissions", true) &&
             Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
         startActivity(new Intent(this, PermissionActivity.class));
         finish();
         return;
     }
    
     setContentView(R.layout.activity_main);
    
     initSettings();
     initViews();
     initActions();
    
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
     setSupportActionBar(toolbar);
    
     FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
     fab.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View view) {
             Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                     .setAction("Action", null).show();
         }
     });
    

    }

    private void initSettings() {
    settings = Settings.get(this);

     if (TextUtils.isEmpty(settings.getMmsc())) {
         initApns();
     }
    

    }

    private void initApns() {
    ApnUtils.initDefaultApns(this, new ApnUtils.OnApnFinishedListener() {
    @OverRide
    public void onFinished() {
    settings = Settings.get(MainActivity.this, true);
    }
    });
    }

    private void initViews() {

     sendButton = (Button) findViewById(R.id.send);
    

    }

    private void initActions() {

     sendButton.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
             sendMessage();
         }
     });
    

    }

    public void sendMessage() {
    new Thread(new Runnable() {
    @OverRide
    public void run() {
    com.klinker.android.send_message.Settings sendSettings = new com.klinker.android.send_message.Settings();
    sendSettings.setMmsc(settings.getMmsc());
    sendSettings.setProxy(settings.getMmsProxy());
    sendSettings.setPort(settings.getMmsPort());
    sendSettings.setUseSystemSending(true);

             Transaction transaction = new Transaction(MainActivity.this, sendSettings);
    
             Message message = new Message("coucou", "0663624241");
    
    
             String path = Environment.getExternalStorageDirectory() +
                     File.separator + "MMSSender_Dir" + File.separator + "Animation.jpg";
             Bitmap imag = BitmapFactory.decodeFile(path);
             message.setImage(imag);
    
    
             transaction.sendNewMessage(message, Transaction.NO_THREAD_ID);
         }
     }).start();
    

    }`

  4. add the necessary permissions, service , receiver in the manifest

The app is compiling and running. When I click on the send button it runs the sendMessage function but the transaction is not sending new message.
With the sample example I can see in the log cat this
V/Transaction: using lollipop method for sending sms V/Transaction: using system method for sending

What did I miss ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant